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 18:46:15 +0100
On 1 Dec 2005, at 06:40, Scott Anguish wrote:
MySingleton* herewegoagain = [MySingleton sharedInstance];
[herewegoagain release]; // <- Will -dealloc be invoked or not?
Incidentally, aside from this ongoing whatever it is about
singletons, that code is incorrect.
If you don't alloc/init or retain it, you have no business releasing
it.
Agreed. I didn't mean otherwise. I was just trying to illustrate that,
for the purposes of this ("ongoing whatever it is about singletons"
:-)) discussion, the only differences between Shaun Wexler's
implementation and the one suggested by Apple's sample code were the
-init problem and complexity.
BTW, sending [sharedInstance release] from within a singleton's class
method, or [self release] from within a singleton's instance method,
_might_ be correct (since sharedInstance was obtained through
alloc/init).
Regards.
_______________________________________________
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