Been wanting something like this for a long time. GAJavaScript
is a Cocoa Touch library that makes working with JavaScript from inside native code much more tolerable, maybe even fun.
JavaScript is accessed from Cocoa Touch using UIWebView. GAJavaScript has the concept of a "script engine", which provides the primary interface to the JavaScript runtime inside the UIWebView. Essentially, the UIWebView is an implementation detail of this library, but you may want to manage the UIWebView instance used by the script engine.
Some might say it's a nasty hack, but in certain situations I can see this totally coming in handy. I work on a product regularly that needs to facilitate complex communication between remote web view content and local native code, and boy, I really wish I'd known about this library back when I started that project.
GAJavaScript
was built by Andrew Goodale and if you like it you should definitely take a look at one of his other projects, GAViewStyling
which is a neat little library letting you style UIView
objects with CSS
style declarations.