iOS3 and Data Persistence

In order to save and retrieve responses from the iPhone, I’ve been looking for technologies to retrieve and create objects through access to a web server. The Surface’s C# methods for retrieving XML documents and writing to them are incredibly straightforward, but Apple apparently rendered their suite of NSXML methods private and therefore unusable on the iPhone for anything but parsing XML. Interesting decision. The KissXML API is supposed to wrap these methods and objects in a way that can be used on the iPhone, but unfortunately I keep getting an error that is driving me mad. No thanks to you, XML – moving on.

On the local side, I could have response objects be created within CoreData, yet the ominous statements from iPhone developers across the globe imply that I’d face a living hell come time to sync the application’s data with a web server. I’ve also looked at SQLite3, but to be frank I’m confused by the little documentation on how to use this with web services.

In fact, web services on the iPhone seem ill covered, or there is no true compendium of possibilities and/or sample code on the internet. What I was led to using is JSON, a lightweight computer data interchange format. This introduction, Andy Jacobs’ tutorials, and these tutorials proved essential to firstly learning what JSON is, learning how to use json-framework, and how to use PHP as a go-between my Objective-C code and my JSON code.

Let’s just say it’s been a marathon two days of educating myself about the different forms of data persistence available, and I’m so pleased with the web services solution I am using. Thanks to the authors of all of the posts above; I am finally able to read and write to a JSON file which can now be used to store responses! Furthermore, because the JSON is being posted by the PHP, I can do any series of things in the PHP such as convert it to XML or MySQL later, and retrieve from there as well in that event.

Excellent. It’s relieving to have this burden off of my shoulders…now, on to the next thing (prettify the interface more, upload images and save their URLs to the JSON file; my tasks for tomorrow).

December 17th, 2009