|ReleasedLast Release||Dec 2014|
Maintained by Unclaimed.
Simple, helpful library for using your Objective-C variables within a bundled AppleScript or OSAScript.
Apple provides NSAppleScript and OSAKit for executing AppleScript in Cocoa, but there is no clear way to execute a script with variables from your Objective-C code, unless you do a long-ass
[NSString stringWithFormat:] like this
NSString *scriptString = [NSString stringWithFormat:@"\ tell application \"Wirecast\"\n\ set myDoc to last document \n\ set desired_shot to the shot named \"%@\" of myDoc\n\ set normal_layer to the layer named \"normal\" of myDoc\n\ set the active shot of normal_layer to the desired_shot\n\ end tell", shotName];
JCAppleScript attempts to provide a simple, sane way of adding AppleScript files to you App bundle and executing them while optionally inserting your Objective-C variables into the script before executing it.
Please fork and submit pull requests if there are additional features or improvements to be made.
Clone the repo
$ git clone https://github.com/johnnyclem/JCAppleScript.git
Drag the JCAppleScript.h and JCAppleScript.m files to your Xcode Project, make sure to check the box to add JCAppleScript to your App's target(s)
In your Objective-C class, import JCAppleScript
[JCAppleScript appleScript:@"tell application \"Finder\"\n\ display dialog \"Hello World\"\n\ end tell"];
tell application "Finder" display dialog $0 $1 end tell
NSArray *myVariables = [NSArray arrayWithObjects:@"Hello", @"World", nil]; [JCAppleScript runAppleScript:@"MyScript" withVariables:myVariables;