tags:

views:

313

answers:

1

Is there any way to tell if a Cocoa application, such as Safari, has finished launching and able to respond? I know it's easy to do using delegates within the actual code but that isn't possible for what I'm doing.

Thanks

+5  A: 

Check out NSWorkspace and NSWorkspaceDidLaunchApplicationNotification. Something like this:

[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(appDidLaunch:) name:NSWorkspaceDidLaunchApplicationNotification object:nil]

The NSNotification object passed to the specified method will contain information about what application launched, its path, etc. For example:

- (void)appDidLaunch:(NSNotification*)note
{
    NSLog(@"app launched: %@", [note userInfo]);
}

EDIT: this is for desktop cocoa applications only - I'm fairly sure this is impossible in Cocoa Touch. Just clarifying that.

Joel Levin