I wish to launch a package file and wait for the install to be finished/closed. Meanwhile the main calling application should be locked until finished.
So far I have tried the following…
- (IBAction)installDriver:(id)sender
{
NSString *file = [[NSBundle mainBundle] pathForResource:@"ExamplePackage" ofType:@"pkg"];
[[NSWorkspace sharedWorkspace] openFile:file];
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(appDidEnd:) name:NSWorkspaceDidTerminateApplicationNotification object:nil];
}
- (void)appDidEnd:(NSNotification *)notification
{
NSLog(@"app info: %@", [notification userInfo]);
}
The problem is the appDidEnd is called whenever any app closes, and in addition unable to detect if ExamplePackage.pkg was the one closed as the userinfo reports installer.app as the closing app.
Any idea on what for what I’m trying to achieve….
Ok found solution after realising the existence of NSTask.
Easy when you know how 🙂