PhoneGap.exec was designed for simple types. Your path is in order, in turn you can just pass your only object (it will work for only one object, see the footer about how we marshal the command), and it should be in the parameter dictionary for the command. Then, on the Objective-C side, use key encoding to automatically populate your custom dictionary object.
eg. MyCustomObject * blah = [MyCustomObject new]; [blah setValuesForKeysWithDictionary: options];
If you are interested in how PhoneGap.exec works, read on ...
* --------- *
For PhoneGap.exec, javascript arguments are bound to a URL.
For the JS command: PhoneGap.exec ('MyPlugin.command', 'foo', 'bar', 'baz', {mykey1: 'myvalue1', mykey2: 'myvalue2'});
Final command URL: Gap: //MyPlugin.myCommand/foo/bar/baz/mykey1 = myvalue1 & mykey2 = myvalue2
It will be processed and converted on the Objective-C side. foo, bar, baz are placed in an array of arguments, and query parameters are placed in the parameter dictionary. It will look for a class called "MyPlugin" and will call the "myCommand" selector using an array of arguments and options as parameters.
For more information see phonegap.js, look at PhoneGap.run_command
source share