I have a Cocoa application with an AppleScript dictionary described in a .sdef XML file. All of the AppleScript classes, commands, etc. defined in the sdef are working property.
Except for my "submit form" command. The "submit form" command is my only command attempting to pass a parameter that is an arbitrary hashtable of information from AppleScript to Cocoa. I assume this should be done by passing an AppleScript record
which will be automatically converted to an NSDictionary
on the Cocoa side.
tell application "Fluidium"
tell selected tab of browser window 1
submit form with name "foo" with values {bar:"baz"}
end tell
end tell
The "with values" parameter is the record
-> NSDictionary
parameter i am having trouble with. Note that the keys of the record/dictionary cannot be known/defined in advance. They are arbitrary.
Here is the definition of this command in my sdef XML:
<command name="submit form" code="FuSSSbmt" description="...">
<direct-parameter type="specifier" optional="yes" description="..."/>
<parameter type="text" name="with name" code="Name" optional="yes" description="...">
<cocoa key="name"/>
</parameter>
<parameter type="record" name="with values" code="Vals" optional="yes" description="...">
<cocoa key="values"/>
</parameter>
</command>
And I have a "tab" object which responds to this command in the sdef:
<class name="tab" code="fTab" description="A browser tab.">
...
<responds-to command="submit form">
<cocoa method="handleSubmitFormCommand:"/>
</responds-to>
and Cocoa:
- (id)handleSubmitFormCommand:(NSScriptCommand *)cmd {
...
}
The "tab" object correctly responds to all the other AppleScript commands I have defined. The "tab" object also responds to the "submit form" command if I don't send the optional "with values" param. So I know I have the basics setup correctly. The only problem seems to be the arbitrary record
->NSDictionary
param.
When I execute the AppleScript above in AppleScript Editor.app
, I get this error on the Cocoa side:
+[NSDictionary scriptingRecordWithDescriptor:]: unrecognized selector sent to class 0x7fff707c6048
and this one on the AppleScript side:
error "Fluidium got an error: selected tab of browser window 1 doesn’t understand the submit form message." number -1708 from selected tab of browser window 1
Can anyone tell me what I'm missing? For reference the entire application is open source on GitHub: