有人可以指出这个工作的一个例子。我只想通过 AppleScript 设置一个属性值。我已经浏览了所有可编写脚本的示例,它们的设置不同。
<?xml version="1.0" encoding="UTF-8"?>
<dictionary title="">
<suite name="Circle View Scripting" code="bccS" description="Commands and classes for Circle View Scripting">
<class name="application" code="capp" description="" >
<cocoa class="NSApplication"/>
<property name="circletext" code="crtx" type="text" description="The text that gets spun into a circle">
<cocoa key="circleText"/>
</property>
<property name="myint" code="crmy" type="integer" description="The text that gets spun into a circle">
<cocoa key="myInt"/>
</property>
</class>
</suite>
头文件:
// header
@interface MyDelegate : NSObject <NSApplicationDelegate>
{
WebScriptObject *scriptObject;
WebView *webView;
NSWindow *window;
NSInteger myInt;
}
// implementation
- (BOOL)application:(NSApplication*)sender delegateHandlesKey:(NSString*)key
{
return key isEqualToString:@"myInt"] || [key isEqualToString:@"circleText"];;
}
-(NSInteger)myInt
{
NSInteger myInteger = 42;
return myInteger;
}
-(void)setMyInt:(NSInteger*)newVal
{
// do nothing right now
NSLog(@"SETTER CALLED");
}
// Applescript 尝试设置属性“myInt”
tell application "BrowserConfigClient"
set myint to 7
properties
end tell
最终,调用了 delegateHandlesKey 方法,我能够为属性返回一个值,但永远不会调用 setter。提前致谢...