Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 389
Christian Nunciato Avatar asked Apr 18 '12 16:04

Christian Nunciato


1 Answers

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

like image 132
JoeCortopassi Avatar answered Oct 28 '22 06:10

JoeCortopassi