How do I pass a file url or path, to a script potentially placed in my app's NSApplicationScriptsDirectory?
I admit I haven't used Applescripts much. Normally I'm able to write what I what to do in regular ObjC but it seems scripting is the only way to achieve what I'm after here. So I drop a script in my apps app script directory and do:
NSURL *urlToPassToScript = //...
NSAppleEventDescriptor *event = [NSAppleEventDescriptor descriptorWithString:urlToPassToScript.path];
NSUserAppleScriptTask *task = [[NSUserAppleScriptTask alloc]initWithURL:script error:&error];
[task executeWithAppleEvent:event
completionHandler:^(NSAppleEventDescriptor * _Nullable result,
NSError * _Nullable error)
{
NSLog(@"Error: %@",error);
}];
I get:
NSLocalizedFailureReason=/usr/bin/osascript: input data for -E was not an event
So what's the proper way to pass a script an argument?