[webkit-dev] WebScripting protocol: valueForUndefinedKey: never gets called
ejpbruel at gmail.com
Tue Nov 17 07:37:51 PST 2009
I am in the process of writing some code in ObjC, which would allow
simple reflection interface (it basically allows you to associated
indices with names, and perform operations such as
getting/setting/calling on these indices).
In order to do this, I created a simple ObjC wrapper object around the
C++ interface, which implements the WebScripting protocol. However,
since this wrapper object does not have any member variables (they
are all hidden behind the C++ interface), I cannot expose these to
Instead, I've tried to make them available using KVC, specifically by
using the methods valueForUndefinedKey: and
setValue:forUndefinedKey:. For isKeyExcludedFromWebScript: and
isSelectorExcludedFromWebScript: I simply always return YES.
Setting properties like this seems to work fine. The method get called,
and I simply forward it to the reflection interface. Getting properties, on
the other hand, does not seem to work: valueForUndefinedKey: simply
does not get called. At all.
I found an entry on the Apple mailing lists of somebody seemingly
having the same problem as me. Unfortunately, there was no answer:
Am I overlooking something? Are there any other methods I need to
override in order for this to work? Or is it simply a bug in WebKit, since
this approach to exposing properties seems to be non-standard, at least.
Any feedback on this issue would be very much appreciated! :-)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the webkit-dev