I am trying to add some scripting functions to a Cocoa application that I wrote. I created a sdef (Scripting Definition File) file for my project. So far, I have managed to access object children (elements) using AppleScript, but I canβt understand for the rest of my life how to call methods (commands).
Here is my sdef file.
<suite name="mySuite" code="mSUI" description="My Application Suite"> <class name="application" code="capp" description="Top level scripting object."> <cocoa class="NSApplication"/> <element description="Test children." type="child" access="r"> <cocoa key="myChildren"/> </element> <responds-to command="testmethod"> <cocoa method="exposedMethod:"/> </responds-to> </class> <class name="child" code="cHIL" description="A Child." plural="children"> <cocoa class="Child"/> <property name="name" code="pnam" description="The child name." type="text" access="r"> <cocoa key="name"/> </property> </class> <command name="testmethod" code="tEST" description="Execute the test method" /> </suite>
Here are my implementations of the controller class (this is the delegate of my application)
Mycontroller.h
MyController + Scripting.m
#import "MyController+Scripting.h" @implementation MyController (Scripting)
Lastly, the AppleScript I'm trying to do:
tell application "MyApplication" testmethod end tell
which answers "AppleScript Error - The variable testmethod is not defined."
Any ideas what I'm doing wrong here? I feel like I'm missing something simple, but my Googling doesn't seem to help anything.
objective-c cocoa applescript
nrj
source share