GAJavaScript is a Cocoa Touch library that makes working with JavaScript easier from native code. It has a couple of important design goals:
- Make working with JavaScript objects and functions more like working with Objective-C objects and methods.
- Allow native applications on iOS devices to take advantage of JavaScript to support sharing code across platforms or making applications more dynamic.
- Don't get in the way of developers!
JavaScript is accessed from Cocoa Touch using UIWebView. To that end, the main entry point of this library is a category on UIWebView.
This category adds accessors to access the "document" and "window" objects of the HTML document loaded in the webview.
This object provides a wrapper around a JavaScript object in a UIWebView. It provides a KVC view for a JavaScript object, so that you can get and set the object's properties using valueForKey: and setValue:forKey:, as you would with other Objective-C classes.
GAScriptObject handles marshaling of data between the languages. It will handle quoting strings, passing dates as "time_t" values, and dealing with sub-objects and arrays.
There are unit tests in the /Tests folder that show how to use various features (and they make sure the features work!).