I can\'t find any instructions how to put a Mac programmatically into sleep mode (in Objective-C). I\'m sure it should be only one line, but could you give me a hint?
I found that running pmset sleepnow worked during a screensaver, while the first two answers did not.
pmset sleepnow