• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
is this enough for a singleton? (for a class cluster "placeholder")
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: is this enough for a singleton? (for a class cluster "placeholder")
      • From: Shaun Wexler <email@hidden>
    • Re: is this enough for a singleton? (for a class cluster "placeholder")
      • From: Shawn Erickson <email@hidden>
  • Prev by Date: Re: Pascal String Woes ...
  • Next by Date: Re: Pascal String Woes ...
  • Previous by thread: Re: Adding/removing rectangles from an NSImageView
  • Next by thread: Re: is this enough for a singleton? (for a class cluster "placeholder")
  • Index(es):
    • Date
    • Thread