• 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: Notify when App quits
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: Notify when App quits
      • From: Matt Jaffa <email@hidden>
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>)

  • Prev by Date: Re: NSTextStorage: Deadlock
  • Next by Date: Re: NSTextStorage: Deadlock
  • Previous by thread: Re: Notify when App quits
  • Next by thread: Re: Notify when App quits
  • Index(es):
    • Date
    • Thread