• 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: Quit helper app when main app terminates
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Quit helper app when main app terminates


  • Subject: Re: Quit helper app when main app terminates
  • From: Stephane Sudre <email@hidden>
  • Date: Thu, 12 Jul 2012 12:54:27 -0700

On Thu, Jul 12, 2012 at 9:33 AM, Jerry Krinock <email@hidden> wrote:
> What is the best way to make a helper app quit when the associated main app quits (or crashes)?  No harm will be done if it keeps running for a minute or so.

A solution that does not involve killing the helper application from
the main application:

Observe the end of the main application from the helper application.

[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
selector:@selector(apocalypseNow:)
name:NSWorkspaceDidTerminateApplicationNotification];

[...]

- (void) apocalypseNow:(NSNotification *) inNotification
{
        NSRunningApplication * tRunningApplication=[[inNotification
userInfo] objectForKey:NSWorkspaceApplicationKey];

        if ([[tRunningApplication bundleIdentifier]
isEqualToString:@"the.bundle.identifier.of.the.main.application"]==YES)
                    [NSApp terminate:self];
}
_______________________________________________

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: 
 >Quit helper app when main app terminates (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: Quit helper app when main app terminates
  • Next by Date: Re: Quit helper app when main app terminates
  • Previous by thread: Re: Quit helper app when main app terminates
  • Next by thread: Re: Quit helper app when main app terminates
  • Index(es):
    • Date
    • Thread