Storing Persistent Data in Hybrid iPhone Webapps

I'm in the process of adding some persistence to a hybrid iPhone webapp. It looks like I'll be using the HTML5 Web Storage capability. I googled around and didn't find any comparisons of the alternatives or suggested best practices. Apple has a document called Safari Client-Side Storage and Offline Applications, which covers Key-Value storage and the JavaScript Database -- but makes no mention of hybrid applications.

It seems there are four possible options:
  1. Web Database
  2. Key-value storage
  3. Cookies
  4. Use a JavaScript to Cocoa bridge to access native persistence
I've given a little thought to the advantages and disadvantages of each (enough to decide to give HTML 5 Web storage a try.)  I'll update this document if I get any good feedback.

Web Database

  • Can be used in hybrid, online and offline webapps.
  • Supported in iPhone OS 2.0 and later.
  • SQL is familiar and powerful for those who know it and need it.
  • Use of SQL is overkill for simple persistence
Key-value Storage

  • Simple conceptual model than SQL
  • Has both "session"and  "local"  modes
  • Only supported in iPhone 3.0 and later (although Apple isn't very clear on this)

  • Tried and true web technology
  • Either not supported in Hybrid mode or requires extra Cocoa code to support.  (Does anybody have a definitive answer, details, or an example?)
  • Extra data is transmitted to the server on each request
  • Others?
Custom JavaScript to Cocoa Bridge Option

  • You can use any iPhone native mechanism for persistence
  • Requires custom Cocoa code
  • JavaScript to Cocoa bridge options are fairly clunky
  • Will not work for pure online/offline webapp


Issues in Serving iUI Sample Apps using Mercurial

Since Google Code does not provide general-purpose web hosting to projects, iUI has long used the SVN repository as an HTTP server to server the sample webapps. For example the URL http://iui.googlecode.com/svn/tags/REL-0.30/samples/music.html serves the Music Sample from the 0.30 release of iUI. We had been using the tag REL-current to always server the latest stable release. We can't (easily) do this with Mercurial because the tag is passed in the query string. The URL http://iui.googlecode.com/hg/samples/music.html?r=REL-current will serve the HTML for the version tagged 'REL-current, but will then try to pull iui.css and iui.js from the 'tip' (at the time of writing, iui.css and iui.js are in a different directory on the 'tip' then they are in REL-current, so the files are not even found. If they hadn't been moved, then the wrong versions would be pulled.)

I'm not sure there is an easy solution to this problem, but if anyone has any ideas, please let me know.

Since we are now deploying the samples to Google App Engine (at http://iui-js.appspot.com), we'll have to have a 'tip' version and a 'REL-current' version on AppEngine, as well. Google App Engine does support deploying multiple versions of a webapp, but I think this is only intended for fallback purposes and not designed for serving multiple versions simultaneously. The other advantage to using AppEngine, of course, is that the dynamic pages used in the Samples and Tests will actually work.


XSLT Book Recommendations

I learned XSLT using Jeni Tennison's Beginning XSLTas a tutorial and Michael Kay's XSLT bookas a reference.  Tennison has a newer book entitled Beginning XSLT 2.0. I'd take a look at her newer book, but keep in mind most XSLT implementations in use today still do not implement XLST 2.0, so don't reject the older book simply because it doesn't cover XSLT 2.0.  If you're hardcore or plan on becoming hardcore,  I'd recommend XSLT 2.0 and XPath 2.0 (it's up to the 4th Edition now.)

If anyone has any other recommendations for learning XSLT, please post a comment...