这个
AMWorkFlow
方法
setValue(_:forVariableWithName:)
和
valueForVariable(withName:)
两者都可以安全地确定该变量是否在工作流文件中设置。
因此,构建一个
工作流管理系统
在你身边
NSUserAutomatorTask
. 只设置脚本正在使用的变量,如
工作流管理系统
:
if let automatorTask = try? NSUserAutomatorTask(url: url) {
if let varChecker = try? AMWorkflow(contentsOf: url) {
automatorTask.variables = POSSIBLE_VARIABLES.filter {
return varChecker.setValue($0.value, forVariableWithName: $0.key)
// -or- //
return varChecker.valueForVariable(withName: $0.key) != nil
}
}
automatorTask.execute(withInput: nil, completionHandler: nil)
}
工作流管理系统
在沙盒中根本不执行,因此必须使用
苏塞拉托马托塔斯克
以实际运行工作流。
do {
try AMWorkflow.run(at: url, withInput: nil)
} catch let error {
print(error)
}
Automator在运行此工作流时遇到错误:
沙盒应用程序不能使用automator.framework来运行工作流。
error domain=com.apple.automator code=0“automator运行此工作流时遇到错误:沙盒应用程序无法使用automator.framework运行工作流。userinfo=nsunderlyingerror=0x604000e498a0 error domain=com.apple.automator code=0”沙盒应用程序无法使用automator.framework运行工作流。“userinfo=nsLocalizedDescription=沙盒应用程序不能使用automator.framework运行工作流。,nsLocalizedDescription=automator在运行此工作流时遇到错误:沙盒应用程序不能使用automator.framework运行工作流。,nsLocalizedFailureReason=沙盒应用程序不能使用automator.framework运行工作流。工作流。}