bridging javascript events to obj-c - performance

Discussion in 'iOS Programming' started by seggenhuber, Mar 7, 2009.

  1. seggenhuber macrumors newbie

    Mar 7, 2009

    I'm developing for iphone and android using phonegap. ( )
    my app needs some objective-c <-> Javascript bridging to pass gestureevents
    back and forth, because i need certain obj-c code to do effects when a user has
    clicked on a certain html element.

    what i found out so far is that the method of using
    document.location="gap:command:params" for executing native code from
    javascript is very very slow. (e.g. my obj-c code gets called once a
    has anyone made any *different experiences?
    is there some way to speed this technique up in a serious way?

    my 2nd approach is to "inject" a JS object und funcs from obj-c
    with stringByEvaluatingJavaScriptFromString , push js-event data into
    an JS array
    and read that data back form obj-c via [self performSelector:mad:selector
    (readJavascriptLogger) withObject:nil afterDelay:0.1] every 0.1 secs
    as described here in the 1st comment:
    this works a lot better, but still is not as fast as i would like it
    to be.
    does this technique has some serious drawbacks?
    is there any better way to this kind of javscriptEvent->objc bridging?
    is there any way to generally boost JS performance on the iphone?

    your help is much appreciated!

Share This Page