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: Uli Kusterer <email@hidden>
- Date: Sat, 26 Nov 2005 18:37:17 +0100
Am 26.11.2005 um 18:09 schrieb Jim Correia:
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.)
The downside is that you'd have to release the current object
before returning the new one. E.g.:
-(id) init
{
if( gSharedObject )
[self autorelease];
else
{
self = [super init];
gSharedObject = self;
}
return gSharedObject;
}
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
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