• 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
Re: Automagic instantiation of singletons?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Automagic instantiation of singletons?


  • Subject: Re: Automagic instantiation of singletons?
  • From: עפרי <email@hidden>
  • Date: Mon, 21 Nov 2005 17:34:33 +0200

In case someone used/want's to use this code, a threading bug was fixed in the last revision ([3212]). Thanks to Jim Correia for noticing that if two threads call sharedInstance when no instance has been created, both can end up allocating a new instance.

- Ofri

On Nov 18, 2005, at 5:36 PM, עפרי wrote:

You may want to take a look at how we do it in Growl (you may even use this code directly as it is released under the BSD license):
http://trac.growl.info/trac/browser/trunk/Core/Source/ GrowlAbstractSingletonObject.h
http://trac.growl.info/trac/browser/trunk/Core/Source/ GrowlAbstractSingletonObject.m


I hope this helps,
- Ofri

On Nov 18, 2005, at 2:47 PM, Jonathan del Strother wrote:


Is there any way to persuade a singleton object to create itself? I have a few singleton objects that need to exist throughout the lifetime of the application, and am currently instantiating them in my application controller's applicationDidFinishLaunching: method.

It would be nice if I didn't have to explicitly do this. My initial thought was that you could do it through the singletons' + (void)initialize method - but of course, this isn't called at application startup - it's only called the first time you try and access the object, so it still needs to be manually set up.


Any other suggestions? I suspect it's not actually possible, but thought I'd throw it out to the obj-c gurus and see what they have to say...


Jon _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com


This email sent to email@hidden




_______________________________________________ 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
References: 
 >Automagic instantiation of singletons? (From: Jonathan del Strother <email@hidden>)
 >Re: Automagic instantiation of singletons? (From: עפרי <email@hidden>)

  • Prev by Date: NSXML and Character References
  • Next by Date: Notification when change is made to the date or time of the System
  • Previous by thread: Re: Automagic instantiation of singletons?
  • Next by thread: Re: Automagic instantiation of singletons?
  • Index(es):
    • Date
    • Thread