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: David Gimeno Gost <email@hidden>
- Date: Thu, 1 Dec 2005 05:52:34 +0100
On 1 Dec 2005, at 05:30, Shaun Wexler wrote:
Sorry for being so dense, but I think I still don't get it:
MySingleton* herewegoagain = [MySingleton sharedInstance];
[herewegoagain release]; // <- Will -dealloc be invoked or not?
No, it will not be dealloc'ed. Once a "hardcore" singleton is
created, it persists until the app quits.
What exactly differentiates your implementation from the one
suggested by Apple's sample code, apart from solving the -init
problem (at the cost of a much, much greater complexity)?
Mine is a thread-safe base class that can be used for nearly all types
of singleton subclasses, and is immune to most programming errors
(alloc+init, re-init, retain/release/copy/etc).
You've completely missed the point of this discussion then, sorry.
_______________________________________________
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