Calling applescripts from a cocoa app

Posts: 133
Joined: 2008.05
Post: #1
I have a cocoa application that I want to run an applescript that tells iTunes to do something.

I don't get any errors and all my file paths seem to be legit, it's just that the script does not do what it does when I run it from the script editor(it does nothing when called from inside the application). I feel I'm missing some sort of link up between iTunes or something, but then again, I don't know. The Applescript does work, it is saved as .applescript. Here is the pieced together code

NSString* resourcePath = [[NSBundle mainBundle] resourcePath];
    NSString* scriptPath = [[NSString alloc] initWithString:resourcePath];
    scriptPath = [scriptPath stringByAppendingPathComponent:@"Untitled.applescript"];
    NSURL* scriptUrl = [[NSURL alloc] initWithString:scriptPath];
    NSMutableDictionary* errorDict = [[NSMutableDictionary alloc] init];
    NSAppleScript* commandTest = [[NSAppleScript alloc] initWithContentsOfURL:scriptUrl error:&errorDict];

    NSAppleEventDescriptor* aeDesc = [commandTest executeAndReturnError:&errorDict];
    [scriptUrl release];
    [scriptPath release];
Quote this message in a reply
Post Reply