Re: Cocoa coding style (was Re: Did I reinvent the wheel?)
Re: Cocoa coding style (was Re: Did I reinvent the wheel?)
- Subject: Re: Cocoa coding style (was Re: Did I reinvent the wheel?)
- From: "Adam R. Maxwell" <email@hidden>
- Date: Sat, 10 May 2008 20:42:40 -0700
On May 10, 2008, at 8:12 PM, Michael Ash wrote:
Even in this case, all you need to do is override -init to return the
shared object. Apple's sample code, showing overrides to -retain,
-release, and other such methods, just serves to hide bugs in the
calling code.
I'd agree with that; I think it's generally more useful to raise an
exception on dealloc to catch the memory management errors. The
sample code also uses @synchronized in +sharedInstance, which turns
out to be surprisingly bad for performance if you happen to call
+sharedInstance in a loop.
There was a very long thread on Apple's singleton example a few years
ago:
http://www.cocoabuilder.com/archive/message/cocoa/2005/11/25/151080
I don't think the example changed significantly as a result, though.
--
adam
_______________________________________________
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