How do I get the returned value from an NSAppleScript. I am using apple script to get the song title in iTunes and take that value and set NSMenuItem's title.
My code: .M
//run applescript
NSAppleScript *script = [[NSAppleScript alloc] initWithSource:@"tell application \"iTunes\" to set song to name of current track"];
[script executeAndReturnError:nil];
//set menu item title
[songName setTitle:script];
My code: .H
IBOutlet NSMenuItem *songName;
You get a NSAppleEventDescriptor
when you execute a NSAppleScript
(not a NSString.
NSAppleEventDescriptor *theResult = [script executeAndReturnError:nil];
//set menu item title
[songName setTitle:[theResult stringValue]];