0

Suppose there are two cocoa apps APP1 and APP2. I want APP2 to be notified when APP1 terminates. I want some callback function registered with APP2 which will be called as soon as APP1 terminates. How can I achieve this? Any sample code will be highly appreciated.

Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140

2 Answers2

2

You can observe the NSWorkspaceDidTerminateApplicationNotification. Its userInfo dictionary contains details about which application was terminated (an NSRunningApplication object).

omz
  • 53,243
  • 5
  • 129
  • 141
0

You certainly looking for NSDistributedNotificationCenter.

Whenever you want to send a notification from One app to Other, just like XCode3.2 and Interface Builder were sending notifications, use NSDistributedNotificationCenter.

This documentation contains sample code such as DockTile, that will come handy to you.

Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140