| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
_______________________________________________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
| References: | |
| >Notify when App quits (From: Matt Jaffa <email@hidden>) | |
| >Re: Notify when App quits (From: Sherm Pendley <email@hidden>) | |
| >Re: Notify when App quits (From: Matt Jaffa <email@hidden>) | |
| >Re: Notify when App quits (From: Manfred Lippert <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.