Is there a way to disable the screen saver and the display sleep with cocoa?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
The use of UpdateSystemActivity(OverallAct) has been deprecated in OSX 10.8.
The recommended approach is now to block it with the following call:
IOPMAssertionCreateWithName(kIOPMAssertionTypePreventUserIdleDisplaySleep,
kIOPMAssertionLevelOn, reasonForActivity, &assertionID);
See this Apple Q&A for further details.
回答2:
i've just solved it and forgot to post it as an answer. Calling UpdateSystemActivity(OverallAct)
every 30 seconds works.