有没有一种程序化的方法来监控Mac何时进入休眠状态?我想要监视用户何时故意告诉系统进入睡眠状态,以及系统何时准备自然睡眠。
发布于 2012-02-01 20:46:58
您可以像这样注册以下通知:
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(receiveSleepNotification:) name:NSWorkspaceScreensDidSleepNotification object:NULL];
您可以像这样注册唤醒通知:
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(receiveWakeNotification:) name:NSWorkspaceDidWakeNotification object:NULL];
https://stackoverflow.com/questions/7680306
复制相似问题