关闭Mac目标C

我需要能够实现以下方法: 关掉 重新开始 注销 睡觉 在Mac上,我正在使用XCode,但似乎无法找出执行这些操作的代码。 有人可以帮我从这里出去吗? 谢谢     
已邀请:
这是一个简单/懒惰的方法,通过一些简单的内联Applescript:
NSString *scriptAction = @"restart"; // @"restart"/@"shut down"/@"sleep"/@"log out"
NSString *scriptSource = [NSString stringWithFormat:@"tell application "Finder" to %@", scriptAction];
NSAppleScript *appleScript = [[NSAppleScript alloc] initWithSource:scriptSource];
NSDictionary *errDict = nil;
if (![appleScript executeAndReturnError:&errDict]) {
    NSLog(@"%@", errDict); 
}
    

要回复问题请先登录注册