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?
|
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? |
||||
|
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.
|
|||||
|
|
Solved! XCode wasn't saving my script file into app's resources path. To run an AppleScript code from Cocoa Application, use this:
|
|||||
|
|
From Apple Documentation https://developer.apple.com/library/mac/technotes/tn2084/_index.html
|
|||
|
|
NSAppleScriptis a public class so will be allowed by Apple's App Store guidelines. – Rob Keniger Feb 6 '11 at 0:48