On Thu, Jul 12, 2012 at 9:33 AM, Jerry Krinock <je...@ieee.org> 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to