Search code examples
cocoamacostermination

Observe other application quit or sudden termination in cocoa app


I need to create wrapper around application, so I created little cocoa app that opens application with [[NSWorkspace sharedWorkspace] launchApplication:…], can I register some event when that application quits or terminates (I certainly need to get event if app is finished good or bad way). I know that I can ask if such application is running every second, but I hope that there is a better way.


Solution

  • Have a look at Technical Note TN2050 "Observing Process Lifetimes Without Polling"

    Particularly the NSWorkspace notifications NSWorkspaceDidLaunchApplicationNotification and NSWorkspaceDidTerminateApplicationNotification