是否有一种编程方式可以监控 Mac 何时即将进入休眠状态?我想监控用户何时故意告诉系统进入休眠状态以及系统何时准备自然休眠。
最佳答案
您可以像这样注册以下通知:
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(receiveSleepNotification:) name:NSWorkspaceScreensDidSleepNotification object:NULL];
您可以像这样注册唤醒通知:
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(receiveWakeNotification:) name:NSWorkspaceDidWakeNotification object:NULL];
关于objective-c - 有没有办法监控 Mac 何时即将进入休眠状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7680306/