I am porting some code from AMWorkflow to NSUserAutomatorTask so that in the end I can isolate my application. I would like to be able to set the value of existing variables in a workflow, as was possible in AMWorkflow, with:
AMWorkflow *task = [[AMWorkflow alloc] initWithContentsOfURL:scriptURL error:nil]; [task setValue:@"myValue" forVariableWithName:@"myVar"];
However, I can't seem to get something like this while working with NSUserAutomatorTask. The only documentation I can find (class reference) indicates that the variables are 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 read in another answer ( Using AMWorkflow with sandboxed software ) that the value specified in "executeWithInput:" for NSUserAutomatorTask is ignored. Is it possible that variables too?
source share