Dav*_*vid 3 macos sleep objective-c nsnotifications
是否有一种程序化的方式来监控Mac何时进入睡眠状态?我想监视用户何时故意告诉系统进入睡眠状态以及系统何时准备自然睡眠.
小智 10
您可以注册以下通知:
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(receiveSleepNotification:) name:NSWorkspaceScreensDidSleepNotification object:NULL];
Run Code Online (Sandbox Code Playgroud)
您可以注册这样的唤醒通知:
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(receiveWakeNotification:) name:NSWorkspaceDidWakeNotification object:NULL];
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1251 次 |
最近记录: |