Is it possible to run an AppleScript code inside an Cocoa Application?
I've tried NSAppleScript class, but no success.
Also, does Apple allow this?
Solved!
Xcode wasn't saving my script file into app's resources path. To run an AppleScript code from Cocoa Application, use this:
NSString* path = [[NSBundle mainBundle] pathForResource:@"ScriptName" ofType:@"scpt"]; NSURL* url = [NSURL fileURLWithPath:path];NSDictionary* errors = [NSDictionary dictionary]; NSAppleScript* appleScript = [[NSAppleScript alloc] initWithContentsOfURL:url error:&errors]; [appleScript executeAndReturnError:nil]; [appleScript release];
1.4m articles
1.4m replys
5 comments
57.0k users