I'm migrating some code from AMWorkflow to NSUserAutomatorTask so that ultimately I can sandbox my app. I'd like to be able to set the value of existing variables within the workflow as was possible in AMWorkflow with:
AMWorkflow *task = [[AMWorkflow alloc] initWithContentsOfURL:scriptURL error:nil];
[task setValue:@"myValue" forVariableWithName:@"myVar"];
However I don't seem to be able to get something similar working with NSUserAutomatorTask. The only documentation I can find (the class reference) says supply the variables as an NSDictionary.
So I'm trying something like:
NSUserAutomatorTask * task = [[NSUserAutomatorTask alloc] initWithURL:workflow error:nil];
task.variables = [NSDictionary dictionaryWithObject:@"myValue" forKey:@"myVar"];
[task executeWithInput:nil completionHandler:^(id result, NSError *error){
if(error)
NSLog(@"Error while executing workflow %@", [error localizedDescription]);
}];
I've read in another answer ( Using AMWorkflow with sandboxed app ) that the value supplied with "executeWithInput:" for NSUserAutomatorTask is ignored. Is it possible the variables are too?