【发布时间】:2014-06-27 22:14:00
【问题描述】:
我正在尝试在我的文档类中创建一个 applescript 命令。我知道我做错了什么,但我不知道该怎么做。
据我了解(可能不正确),当我创建一个新命令时
我需要为该命令指定一个新类。但是从那个新班级,让我们称之为
ScriptResetCommand,如何通过performDefaultImplementation 方法访问文档对象? applescript 调用类似于
tell document 1 of application "DocScript" to simple reset
这是我当前的代码: ScriptResetCommand.m 文件:
@implementation ScriptResetCommand
- (id)performDefaultImplementation {
// Somehow I need to access the correct document class and
// perform my reset.
NSLog(@"ScriptResetCommand performDefaultImplementation");
return @"Reset Stuff";
}
ScriptResetCommand.h 文件:
@interface ScriptResetCommand : NSScriptCommand
- (id)performDefaultImplementation;
.sdef 文件:
<command name="simple reset" code="jDsgSrst" description="run a simple reset">
<cocoa class="ScriptResetCommand"/>
<result type="text" description="returns the result"/>
</command>
因此,使用此代码,我可以成功调用 ScriptResetCommand 类中的 performDefaultImplementation 方法,但是如何访问其中包含所需 reset 命令的 Document 对象?
提前致谢。
【问题讨论】:
标签: objective-c macos cocoa applescript