Get Updates By E-mail 

Article Written By:
Johann Dowa

Open Source: Library For Easily Communicating With Objective-C Code From A UIWebView

  •  
  •  
  •  
  •  
  •  

I’ve mentioned in the past instances when you may want to use a UIWebView for tasks such as rendering .SVG files, but there could likely be instances when you want to go the other way. I see questions on how to do this popping up time and time again.

Communicating with the webview itself is easy as you can execute Javascript code using the UIWebView stringByEvaluatingJavaScriptFromString but going the other way things can get a bit hacky.

I’ve come across a very easy to use Javascript and Objective-C  library that allows for two way communication with a UIWebView with just a few lines of code.

The library is from Marcus Westin and can be found with full documentation, and an easy to understand example here:

https://github.com/marcuswestin/WebViewJavascriptBridge

If you ever find yourself struggling to get some Javascript running in a UIWebView to communicate with your Objective-C code you can use this library which makes things a snap, and of course since it’s open source you can take a look at how things are done.


  •  
  •  
  •  
  •  
  •  

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments