ios - How to call subfunction in JavascriptCore? -


i'm using javascriptcore in app, having troubles. javascript structure this:

var restaurant = function() {     this.street = function()     {         return "one street 45";     }      this.postal = function()     {         return "90210";     } } 

now, in javascript created function allows restaurant add map:

addmetothemap(restaurant); 

and in jscontext maps to:

self.context[@"addmetothemap"] = ^(jsvalue *restaurant) { }; 

what find difficult though able call street , postal functions. tried doing [[restaurant callwitharguments:nil] @"street"] callwitharguments:nil], didn't work. ideas?

why

think you're logically saying in [[restaurant callwitharguments:nil] @"street"] callwitharguments:nil].

you don't have return statement in restaurant function in javascript. [restaurant callwitharguments:nil] return void.

also street , postal both return strings. not this, therefore [[... @"street"] callwitharguments:nil] trying call string function. not mention shouldn't compile because of [... @"some string"].

what want

what want use objectforkeyedsubscript: method on jsvalue returns jsvalue. instead of using callwithargs. should like:

[restaurant[@"street" <or> @"postal"] callwitharguments:nil] 

which return string wrapped in jsvalue. can unwrap using tostring.


Comments

Popular posts from this blog

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

javascript - Confirm a form & display message if form is valid with JQuery -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -