2011-11-10 13 views
1

私はテストAppleScript辞書を持っている:スクリプティングのCocoaアプリケーション

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd"> 

<dictionary title="ScriptTest Terminology"> 

    <suite name="Standard Suite" code="????" description="Common classes and commands for all applications."> 
     <class name="application" code="capp" description="The application's top-level scripting object."> 
      <cocoa class="NSApplication"/> 
     </class> 
    </suite> 


    <suite name="MyApplication Suite" code="scts" description="MyApplication information."> 
     <class name="application" code="capp" description="The application's top-level scripting object." inherits="application"> 
      <cocoa class="NSApplication"/> 

      <responds-to command="sayhello"> 
       <cocoa method="sayHello:"/> 
      </responds-to> 

     </class> 

     <command name="sayhello" code="sctshell" description="Says hello."> 
     </command> 
    </suite> 

</dictionary> 

私AppDelegateが持つメソッド:しかし、それが呼び出されないです

- (void)sayHello:(NSScriptCommand*)scriptCommand; 

を...なぜ?

appleScriptのアプリケーションクラスにコマンドを追加するにはどうすればよいですか? (例えば、tell application "Test" to sayhello)?

答えて

0

AppleのSimpleScriptingVerbsサンプルコードを見てください。その後

<command name="sayhello" code="sctshell" description="Says hello."> 
    <cocoa class="SayHelloCommand"/> 
</command> 

NSScriptCommandのサブクラスとしてSayHelloCommandを実装し、そのperformDefaultImplementationメソッドをオーバーライドします:するsayHelloコマンドのあなたのsdef定義は、コマンドを実装NSScriptCommandのサブクラスに名前を付ける必要があります。

関連する問題