• 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: Mic Pringle <email@hidden>
  • Date: Fri, 13 Mar 2009 13:13:57 +0000

Yep. This looks like the best solution. Will give this a go.

Thanks

-Mic

2009/3/13 Dave DeLong <email@hidden>:
> 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
>
_______________________________________________

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

References: 
 >Re Singleton Help ... (From: Peter Hudson <email@hidden>)
 >Re: Re Singleton Help ... (From: Dave DeLong <email@hidden>)

  • Prev by Date: Re: Re Singleton Help ...
  • Next by Date: Re: code for drawing an NSTextField to a panel window ...
  • Previous by thread: Re: Re Singleton Help ...
  • Next by thread: NSPredicate & live filtering question
  • Index(es):
    • Date
    • Thread