This is my first time using WebKit so I'm rather stumped with how I should be handling this problem. I want to to interact with an array in Obj-C that was created in Javascript (documentation says JS array -> Obj-C is wrapped in a WebScriptObject). But the problem is other types can be returned, so I'm not sure how I check to make sure it's an array before using "webScriptValueAtIndex:" to get the data from it.
Since the only two ways I see you can check is going ahead with trying to access it using webScriptValueAtIndex: and just check to see if the result is WebUndefined or not. But that doesn't seem like the right way to go about it, so the other way is getting the JSObjectRef and copying it's property names and calling JSPropertyNameArrayGetCount to see if it returns a size greater than 0. So even though this seems a bit better, it isn't really telling me whether it is an array or not (e.g. could be an empty array).
So what is the correct/suggested way to go about this?
Since the only two ways I see you can check is going ahead with trying to access it using webScriptValueAtIndex: and just check to see if the result is WebUndefined or not. But that doesn't seem like the right way to go about it, so the other way is getting the JSObjectRef and copying it's property names and calling JSPropertyNameArrayGetCount to see if it returns a size greater than 0. So even though this seems a bit better, it isn't really telling me whether it is an array or not (e.g. could be an empty array).
So what is the correct/suggested way to go about this?