Re: Notify when App quits
Re: Notify when App quits
- Subject: Re: Notify when App quits
- From: Manfred Lippert <email@hidden>
- Date: Wed, 3 Mar 2004 18:31:04 +0100
I was looking into this,
will registering for a notification center like this inform me? Cause
it is not working so far.
And what type of apps will it inform me on?
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(NotifyMe:)
name:@"NSApplicationWillTerminateNotification" object:nil];
Is this wrong?
I think the name @"NSApplicationWillTerminateNotification" is wrong. If
you use the predefined string
NSWorkspaceDidTerminateApplicationNotification (defined in
NSWorkspace.h) it will work as expected:
[[[NSWorkspace sharedWorkspace] notificationCenter]
addObserver:self
selector:@selector(applicationDidTerminate:)
name:NSWorkspaceDidTerminateApplicationNotification
object:nil];
In your selector "applicationDidTerminate:" you could e.g. do the
following:
- (void)applicationDidTerminate:(NSNotification *)notification {
if ([[[notification userInfo] objectForKey:@"NSApplicationName"]
isEqualToString:@"Safari"]) {
NSLog(@"Safari has quit!");
}
}
All terminating apps will be notified to you.
Regards,
Mani
_______________________________________________
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.