Alex Rivera | Logout

Calling Obj-C Code from JavaScript via Console: Arguments get dropped?

Asked 2012-04-18T16:27:44.293
9

Having a heck of a time with this one.

I've got a super-simple Cocoa app containing one WebView, a WebScripting API defined in the page, and a single NSObject defined on that API. When I turn on the debugger tools (in the embedded WebView), I can see the API on the JavaScript window object, and I can see my "api" property defined on that -- but when I call the API's "get" method, the arguments aren't being serialized -- when the Obj-C method gets called, the arguments are missing. See below, which hopefully illustrates:

enter image description here

I've combed through the docs, I've (apparently) set the appropriate methods to expose everything that needs to be exposed, and I can see the method being called. There has to be something stupid I'm missing, but as a relative newbie to this environment, I'm not seeing it.

Thanks in advance for your help!

Edit
Report

1 Answer

2

Have you set WebKitDeveloperExtras to YES in your default user defaults when you send -[NSUserDefaults registerDefaults:]?

answered 2012-05-01T19:34:24.367

Your Answer