Re: Web scripting key does not work

aglee <[email protected]> Wed, 20 Oct 2010 16:52:17 +0000 (GMT)
Newsgroups gmane.comp.macosx.devel
Message-ID <[email protected]>
On Oct 20, 2010, at 11:17 AM, Christiaan Hofman <[email protected]> wrote:
is its value the property value, or is it the *function* that retrieves the property value?  


This is the property, that should also be obvious from the JS statement I gave. As i said, I am talking about the key access, not the selector access.
 
I understood what you were *trying* to get, it just wasn't clear to me how that could work.

My flawed assumption was that if calling the setter via setFoo_() worked, calling the getter via foo() must work too.  But it doesn't, as I just checked  Dot notation for properties works as you'd expect.

To illustrate, if in the JavaScript I do alert(window.myObject.foo), the alert message is:

function foo() {
    [native code]
}
 
This was my fault.  I forgot to implement isKeyExcludedFromWebScript:.  Or rather, I forgot to uncomment it, having commented it out after some experiments a while back.  Therefore "foo" didn't get the special "this is a property" treatment and the method -foo was assigned as the "foo" property of the JavaScript object.  Once I fixed that, my JavaScript property access worked just like in the CallJS example.

Christiaan, it looks to me as it looks to you: your code "should" absolutely work.  The only things I can think of (in increasing order of desperation):

* Make sure you aren't getting a JavaScript error, which might be silently killing your script.  By doing this -- http://twitter.com/danielpunkass/status/7502286887 -- you can right-click the WebView and open a console that will log any JavaScript errors.  Come to think of it, this is a quick way to test various JavaScript statements too on the fly.

* Make sure isKeyExcludedFromWebScript: is being called, with an NSLog.

* Try having it return NO always, just for grins.

And with that, I'm out of ideas, so I hope you (or someone else) figures it out.

--Andy