-1

I call and execute apple script in main thead below

NSAppleScript *as = [[NSAppleScript alloc]
initWithSource:@"tell application \"Finder\" to sleep"];
[as executeAndReturnError: NULL];
[as release];

but does not work, while the script

tell application Finder to sleep

works well in AppleScript Editor.

your comment welcome

mklement0
  • 382,024
  • 64
  • 607
  • 775
arachide
  • 8,006
  • 18
  • 71
  • 134
  • It doesn't work? What happens? – paulmelnikow Apr 26 '14 at 03:28
  • This probably won't solve your problem, but it's worth noting that using the `"System Events"` context is the better choice - `"Finder"`'s `sleep` command is in the `Legacy` suite. Also, I assume you meant to double-quote `Finder` in your 2nd snippet. – mklement0 Apr 26 '14 at 03:47
  • if use "System Events", I can not find the suitable com.apple.security.temporary-exception.apple-events – arachide Apr 26 '14 at 14:45

1 Answers1

4

This is the way to examine the result and error from -executeAndReturnError:

NSDictionary *errors = nil;
NSAppleEventDescriptor *result = [as executeAndReturnError:&errors];
NSLog(@"result: %@", result);
NSLog(@"errors: %@", errors);
paulmelnikow
  • 16,895
  • 8
  • 63
  • 114