-1

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;
atomikpanda
  • 1,845
  • 5
  • 33
  • 47

1 Answers1

4

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]];
jackjr300
  • 7,111
  • 2
  • 15
  • 25