Re: bindings duplicates object returned
Re: bindings duplicates object returned
- Subject: Re: bindings duplicates object returned
- From: Eric Slosser <email@hidden>
- Date: Tue, 13 Dec 2011 14:26:37 -0500
On Dec 13, 2011, at 1:47 PM, Kyle Sluder wrote:
> Don't be tempted to add singleton smarts to -[Foo init]. ARC will not
> like them. Instead, add a property to File's Owner that just returns
> the shared Foo instance.
Really? Do you have a reference for that claim? I looked through http://clang.llvm.org/docs/AutomaticReferenceCounting.html and saw nothing about singletons.
So much has been written about how -init is allowed to return a value other than what 'self' was at entry, I can't believe ARC can't handle it.
FWIW, here's the body of my singleton-smart -init.
if ( gSingleton!=NULL )
{
[self release];
self = gSingleton;
}
else if ((self=[super init])!=NULL)
{
…
}
return self;
_______________________________________________
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