That would work. However, you lose out on being able to declare "foo" as an @property (not a big deal) and have to write the accessors yourself (annoying, since the compiler knows how to do this already but can't in this case).
Dave On Aug 1, 2011, at 9:05 AM, Dave Zarzycki wrote: > The simplest and most ARC friendly way to implement the singleton pattern is > to switch from instance methods to class methods – because the class itself > is by definition a singleton. In other words: > > + (MyClass *)sharedInstance; > // and maybe override alloc/retain/release to enforce the singleton > pattern > - (int)foo; > - (void)setFoo:(int)val; > > …becomes simply: > > + (int)foo; > + (void)setFoo:(int)val; > > davez > > > On Aug 1, 2011, at 8:48 AM, Jeff Kelley wrote: > >> Is there a new recommended way to implement a singleton with ARC? I remember >> hearing something about it, but I’m not sure what it was. >> >> Jeff Kelley >> _______________________________________________ >> >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >> >> Please do not post admin requests or moderator comments to the list. >> Contact the moderators at cocoa-dev-admins(at)lists.apple.com >> >> Help/Unsubscribe/Update your Subscription: >> http://lists.apple.com/mailman/options/cocoa-dev/zarzycki%40apple.com >> >> This email sent to zarzy...@apple.com > > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > http://lists.apple.com/mailman/options/cocoa-dev/davedelong%40me.com > > This email sent to davedel...@me.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com