Presto, chango

16 August, 2011 12:57 by Simon S

In my last post I described how to build the file that contains the initial load data for your field guide. At the same time, I sent the code off to an external beta tester. He came back with the question: How do I change the data once its been loaded by the app? When we were testing of the field guide, if we needed to change the data, I just reset the simulator or deleted the app from the testing device.

Not something you can really do once you've released your app to production.

So, with a couple of changes to code, we have two new properties. One in the animalData.plist file called versionID and another in CustomSettings.plist called currentDataVersion. The value of these two properties should always be identical. The first time the app is run on a device, the database is set up and the value for versonID is stored in the database. On subsequent start-ups, the app compares the value of versionID stored in the database against the value of currentDataVersion from CustomSettings.plist. If they're different, the app clears the database and reloads it from animalData.plist.

Why are we storing the same value in two different plist files? If you've got a lot of species in the app, the animalData file will contain a lot of information. It is overkill to parse this file every time the app starts just to find a short string. Since CustomSetting.plist is already loaded every time the app runs, it's the perfect place to put the check value.

Adding versionID as a property to animalData.plist has resulted in a change to the structure of that file. It was an array of arrays, like this

(

(array of taxon data),

(array of animal data),

)

The code determined the content by an element's position in the array. The file is now structured as a dictionary, like so:

{

taxonList=(array of taxon data);

animaldata=(array of animal data);

versionID = 1.0;

}

It's a small change, but it means that any future additions to the list will be easy to incorporate. Here's a new example animalData.plist file and a CustomSettings.plist file for your perusal.

<< Getting your data out  |  30 days hath September, April, mumble and November... >>

Comments (1)

sort by
newest
oldest
Julian 31 August, 2011 12:59
This looks great. How easy would it be to update the list without sending out an app update (i.e. loading the list from a web server)?
reply
Write your comment below All fields are required

We love receiving comments, but can’t always respond.

About this blog

We've released the source code for MV's Field Guide Project under a MIT style license. This blog will help you identify all the material you need to collect so that you can publish a field guide of your own.

MV's Open Sourced Code on Github

View all Museum Victoria's apps

Blog authors

Simon S is the programmer behind the field guide app.

Simon O is the designer behind the field guide app.