Run AppleScript from Cocoa Application?

You mentioned xcode wasn't saving the script to your app's resources path. That is correct. You have to tell xcode to do this.

First add the compiled script to your project. Then open your target and find the "Copy Bundle Resources" action. Drag your script from the files list into that action.

This way your script is copied to your app's resources automatically so you don't have to do it by hand.

Up vote 2 down vote favorite 3 share g+ share fb share tw.

I've tried NSAppleScript class, but no success. Also, does Apple allow this? Objective-c cocoa applescript link|improve this question edited Aug 13 '11 at 2:36 asked Feb 5 '11 at 21:15Fábio Perez894416 100% accept rate.

NSAppleScript is a public class so will be allowed by Apple's App Store guidelines. – Rob Keniger Feb 6 '11 at 0:48.

You mentioned xcode wasn't saving the script to your app's resources path. That is correct. You have to tell xcode to do this.

First add the compiled script to your project. Then open your target and find the "Copy Bundle Resources" action. Drag your script from the files list into that action.

This way your script is copied to your app's resources automatically so you don't have to do it by hand. Whenever I use a compiled applescript in a cocoa application I, 1) add the script to the project, 2) create a new class to control the applescript, 3) use the below init method for the class, and 4) drag the script to the "Copy Bundle Resources" action of the target. -(id)init { NSURL* scriptURL = NSURL alloc initFileURLWithPath:NSBundle mainBundle pathForResource:@"applescripts" ofType:@"scpt"; if (self initWithURLToCompiledScript:scriptURL!

= nil) { //attempt to load the script file } scriptURL release; return self; }.

Thanks. Problem solved. :) – Fábio Perez Feb 7 '11 at 18:48.

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.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions