You probably want to check NSWorkspaceWillSleepNotification in NSWorkspace .
The trick is that you need to register for notifications at the NSWorkspace notificationCenter, not the default. See Technical Q & A QA1340 .
Code example:
- (void) receiveSleepNote: (NSNotification*) note { NSLog(@"receiveSleepNote: %@", [note name]); } - (void) fileNotifications {
source share