title: How to send events from HTML running inside a UIWebView to native Objective-C code?
body: <p>I want to integrate a full HTML framework (ie HTML/CSS/JavaScript) inside an iOS app and make the UIWebView in charge of running the HTML content being able to communicate with the rest of the native Objective-C source code.</p>
  
  <p><strong>Direction 1: from Objective-C to HTML inside a UIWebView</strong></p>
  
  <p>The way to make the rest of the source send messages to the HTML content is pretty straightforward: i can just call <code>stringByEvaluatingJavaScriptFromString:</code> on the Objective-C side and implement JavaScript methods the right way.</p>
  
  <p><strong>Direction 2: from HTML inside a UIWebView to Objective-C</strong></p>
  
  <p>This is the way I can't really figure out. My only idea so far is to make my app a local web server and make the HTML request stuff to it. But I have no idea how to do that although I suppose it can be bone as I believe apps such as Things, VLC or 1Password might use this kind of features.</p>
  
  <p>Any idea to make this <em>direction 2</em> work or any new perspective to make events inside HTML content being sent to Objective-C code is welcome.</p>