1

how do you find out when a cocoa application has been closed, minimized or tabbed?

I have read up on NSNotifications however, I still cannot understand how I can find out when the user has done any of the 3 actions above.

Thank you for any input

Kevin
  • 1,469
  • 2
  • 19
  • 28
  • possible double-post of [Cocoa Close/Hide/Change Tab Notification](http://stackoverflow.com/questions/9826719/cocoa-close-hide-change-tab-notification) – jscs Mar 27 '12 at 04:39

1 Answers1

2

Have your controller class conform to the NSWindowDelegate protocol and implement windowWillMiniaturize: and windowWillClose: and they will be called just before the window does the action.

Do the same with the NSTabView delegate protocol and implement tabView:willSelectTabViewItem:.

Some cocoa classes also send out notifications that are the same or similar to their delegate protocol, for example: NSWindow Notifications. You can use NSNotificationCenter to listen to these events. You have to look at the documentation to find out what exists.

Nathan Kinsinger
  • 23,641
  • 2
  • 30
  • 19