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: Shaun Wexler <email@hidden>
- Date: Thu, 1 Dec 2005 19:29:13 -0800
On Dec 1, 2005, at 7:17 PM, mmalcolm crawford wrote:
On Dec 1, 2005, at 7:02 PM, Shaun Wexler wrote:
@interface MortalSingleton : NSObject
[...]
No, fails:
Ensures that dealloc is not called prematurely (to avoid expensive
re-instantiation).
This class was created to address the original poster's problem; I
thought he wanted a singleton class which would allow deallocation
when no longer needed, as per standard Cocoa memory management
rules. In contrast, my "hardcore" SKWSingletonObject class is Immortal.
To implement MortalSingleton subclasses, you'd need to add a sanity
test to prevent re-init, if applicable, and to make it semi-immortal,
simply create a class accessor method which retains the
sharedInstance until dealloc is prudent.
--
Shaun Wexler
MacFOH
http://www.macfoh.com
"It would be a sad situation if the wrapper were better than the meat
wrapped inside it." - Albert Einstein
_______________________________________________
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