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.