Re: Re Singleton Help ...
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