• 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: Re Singleton Help ...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re Singleton Help ...


  • Subject: Re: Re Singleton Help ...
  • From: Dave DeLong <email@hidden>
  • Date: Fri, 13 Mar 2009 06:57:04 -0600

Similarly, couldn't you have the singleton itself register to receive the applicationWillTerminate notification? I don't think it has to be done via the app's delegate.

Something like:

(in your singleton's accessor, or perhaps a private initializer?)
[[NSNotificationCenter defaultCenter] addObserver:_singletonInstance selector:@selector(appIsQuitting:) name: NSApplicationWillTerminateNotification object:NSApp];


Then in your appIsQutting: method, just do:
[[NSNotificationCenter defaultCenter] removeObserver:self];

HTH,

Dave

On Mar 13, 2009, at 6:49 AM, Peter Hudson wrote:

I had a very similar situation using a singleton and found that I needed to remove it from the notification centre before the app died - or landed up with an odd side effect (main menu items in xCode would no longer respond to the mouse ).

I fixed it by getting the app delegate to respond to applicationShouldTerminate: and removed my singleton from the notification centre there. The menu problems went away.

PH
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Re Singleton Help ...
      • From: Mic Pringle <email@hidden>
References: 
 >Re Singleton Help ... (From: Peter Hudson <email@hidden>)

  • Prev by Date: NSPredicate & live filtering question
  • Next by Date: Re: Re Singleton Help ...
  • Previous by thread: Re Singleton Help ...
  • Next by thread: Re: Re Singleton Help ...
  • Index(es):
    • Date
    • Thread