0

誰かがこの作業の例を教えてくれますか? 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 は呼び出されません。前もって感謝します...

4

1 に答える 1

1

メソッドステートメントにエラーがあります...

-(void)setMyInt:(NSInteger*)newVal

NSInteger は「ポインター」変数ではないため、「*」は使用できません。あなたの質問のコメントで、Ken Thomases がすでにこれを伝えていることがわかりますので、必ず修正してください。

これが問題でない場合は、sdef ファイルを確認してください。辞書タグを閉じていないことがわかります。これは、そのファイルの最後の行として必要です。

</dictionary>

また、これは sdef ファイルの 2 行目にあります...

<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">
于 2012-04-10T15:20:26.613 に答える