I need to be able to implement methods of:
On a Mac, I am using XCode but can't seem to figure out the code to perform these actions.
Can anyone help me out here?
Thanks
A trivial/lazy way do this is via some simple inline 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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With