Re: ARC and Singletons
Re: ARC and Singletons
- Subject: Re: ARC and Singletons
- From: Dave Zarzycki <email@hidden>
- Date: Mon, 01 Aug 2011 09:05:25 -0700
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 (email@hidden)
>
> 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:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden