0
我想了解使用XCode 5为OSX Automator创建的操作。如何将AppleScript变量的内容传输到Objective-C操作
所以我用的模板 “的Automator动作” 是这样的:
- (id)runWithInput:(id)input fromAction:(AMAction *)anAction error:(NSDictionary **)errorInfo
{
// we expect to receive "Hello World" in the input variable
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDesktopDirectory, NSUserDomainMask, YES);
NSString *desktopDirectory = [paths objectAtIndex:0]; // Get desktop directory
NSString *logStr = @"";
logStr = [ NSString stringWithFormat:@"founded %lu", (unsigned long)[input count]];
[ logStr writeToFile:[ desktopDirectory stringByAppendingPathComponent:@"log.txt" ] atomically:YES encoding:NSUTF8StringEncoding error:nil ];
return input;
}
在Automator中,我创建了2个步骤:
第一:一个AppleScript动作,做这个:
on run {input, parameters}
return "Hello World"
end run
正如你可以看到它只是返回文本“Hello World”
二,我的我使用Xcode创建的操作。
但是,当我运行工作流程......没有错误,但输入参数(这是一个NSArray)不包含任何内容!
你知道如何将AppleScript变量的内容传递给Objective-C动作吗?
谢谢你的帮助。