Re: Is Apple's singleton sample code correct?
Re: Is Apple's singleton sample code correct?
- Subject: Re: Is Apple's singleton sample code correct?
- From: Jim Correia <email@hidden>
- Date: Sat, 26 Nov 2005 12:09:38 -0500
On Nov 26, 2005, at 12:02 PM, Uli Kusterer wrote:
But isn't that dangerous? That would mean that calling alloc/init
on such an object would repeatedly call init on the same object :-(
You'll have to ask the person who wrote the sample :-)
Yes, initializing an object twice is generally a bad idea. AppKit
doesn't expect you to do that, and the result will range from leaks
to incorrect behavior.
If you want to enforce singleton-ness, perhaps returning a
replacement object from the designated initializer is a better idea.
(Or perhaps not - there may be reasons not to do that which aren't
obvious to me right now.)
Jim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden