Calling Javascript in an iOS web app from Objective-C

Question!

I am developing a web app that is being displayed in a UIWebView. The app is loaded locally, i.e, not from a web server. I am communicating from Javascript to ObjC via the shouldStartLoadWithRequest: method in the UIWebViewDelegate protocol.

The last thing I need is to be able to call Javascript functions from ObjC without any page reloads. I hope this is possible.



Answers

One can use JavaScriptCore framework to run JavaScript code from Objective-C.

#import 
By : Evgenii


Could't you just do this by doing a "loadRequest", and passing it an NSURL with contents like like:

javascript:myFunction("MyParameter");

It should call your function, but not reload the page.

By : Brad


This video can help you solving your question :)
By: admin