What is Macintosh OSX equivilent to Windows WM_POWERBROADCAST message
I'm a Windows developer, but my team counterpart on the Mac side has asked me for help with an issue our Mac client has when the user wakes up his computer from hibernation.
I handle the wake up situation in our Windows client using the Windows WM_POWERBROADCAST message. This is a message that Windows sends to applications whenever there is a change in the power state of the hardware (on/off/suspend/resume).
Does O开发者_JS百科SX support a similar notification to tell running applications that the computer is suspending, resuming, or powering up or down?
TIA.
NSWorkspace
has a bunch of notifications you can listen for.
Sorry, edited because the first post was completely wrong. NSWorkspace
doesn't use the default notification center for notifications. This is copied mostly out of Apple's docs.
NSNotificationCenter *notCenter;
notCenter = [[NSWorkspace sharedWorkspace] notificationCenter];
[notCenter addObserver:self
selector:@selector(didWake:)
name:NSWorkspaceDidWakeNotification
object:nil];
精彩评论