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

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -