问题
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.
来源:https://stackoverflow.com/questions/5126953/how-to-disable-the-screen-saver-display-sleep-on-mac