0

I'm trying to write some bridge between Javascript, which is called from UIWebView, and Objective-C calls. I find a lot of quiestions like that, and all of them saying that I should catch Javascript calls in

-(BOOL) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType

ok, it's easy (and only?) way to do this, so I'm looking to that direction.

All answers to these quiestions say "parse url from webView and then with help of if-else send a message to Objective-C class". I have more than 10 functions in Javascript, so I don't want to parse them manually (these functions will have arrays of js objects as parameters and so on).

So the question is: are there any light libraries or opensource projects to convert/unconvert obj-C selectors and parameters into/from strings? (I am not so familiar with Javascript, but I think that do the same thing in much easy than in obj-C, so the main question is about obj-C)

PS I've found QuickConnectOC library, but I'm not sure if I can use it PPS I think it is not difficult to write my own parser... but I don't want to reinvent wheel

2
  • stackoverflow.com/questions/3275093/… Commented Jun 26, 2012 at 21:46
  • and if I have function like this: addSomething(a, b, [{q:3}, {w:5}]) ? I dont want to write own parser which should do more than separate parameters Commented Jun 26, 2012 at 21:51

1 Answer 1

0

the best solution seemed to be:

in js: to make string from method's name you need to call, then add to string js parameters as one object with stringify, then send this string to WebView

in objC: get by my own method's name, then use jsonkit to get complete dictionary with parameters (which can be arrays of dictionaries etc)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.