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 (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 [EMAIL PROTECTED]

Reply via email to