Try use this part part code
-(IBAction)goAway:(id)sender{
SystemEventsApplication *systemEvents = [SBApplication applicationWithBundleIdentifier:@"com.apple.systemevents"];
[systemEvents sleep];
}
But couldn't find from where import SystemEventsApplication and couldn't import SystemEvents.h
Find this solution here Programmatically put a Mac into sleep
Copyright Notice:Content Author:「shami13」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/17245703/couldnt-import-systemeventsapplication