is this enough for a singleton? (for a class cluster "placeholder")
is this enough for a singleton? (for a class cluster "placeholder")
- Subject: is this enough for a singleton? (for a class cluster "placeholder")
- From: Ben Dougall <email@hidden>
- Date: Wed, 11 Feb 2004 21:22:46 +0000
i got this code from the archives for a singleton object:
+ (id)allocWithZone:(NSZone *)zone {
if ([MyAbstractClass self] == self)
return NSAllocateObject([MyConcreteClass self], 0, zone);
return [super allocWithZone:zone];
}
don't quite understand it -- will that give an ok/perfectly fine
singleton implementation? usually the singleton implementations that
i've seen involve a static variable in the class, but i know there's a
variety of ways to do singletons. is there something else that needs to
be done further to the above code, or is that it, so far as the
singleton aspect of it goes?
(not sure if this throws a different light on it or not -- both the
above code and what i want a singleton for, is for the abstract class
of a class cluster - a placeholder - the thing that vends as it were.
the above code is from here:
<
http://cocoa.mamasam.com/COCOADEV/2001/09/2/12499.php>)
thanks, ben.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.