Re: Quit helper app when main app terminates
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