I have a large number of nested dictionaries and the leaf (or most nested) dictionaries store integer data and integer keys. All the information remains constant (but may change in a future release). I am currently allocating the dictionaries from constants in code but I feel I should be reading that information from XML or similar. I have read about Core information, plists, databases and archives but I don’t want the user to be able to change it, I never want to be able to write it (except maybe during the release procedure) and I never want to display it. I would like to be able to hand edit it before release.
What is the best method to store this constant data?
Basically you need to ship your data in files with the app –
XML or JSONare both suitable for this. When I have had to do something similar I used JSONIt works something like this :
Define your
JSONin text file (UTF8) and then use theNSString initWithContentsOfFileto load file contents into aNSStringYou can then use the
NSJSONSerialization JSONObjectWithDatato give you the top level dictionary for yourJSONFrom this you can extract your
NSStrings / NSArraysusingNSDictionary objectForKeyfor your data. Obviously the exact format will depend on yourJSONformat