I’ve working on an App that needs to call up some information from a file each time it runs. This info will be loaded into three array, two with text, one with int. The info being loaded (and subsequently written back when app closes) could get long at some stage.
I’m working what the best file format to save and recall this in is? I want to try and avoid using a database just now if possible for various other reasons.
I know I could use a standard text file and then delimit each segment with something but I’m not sure how to work a delimited over a few lines. e.g. it could be 3 or 4 lines in the text file before the delimited is found.
I’ve used XML before in other languages but IOS doesn’t seem to support this natively, or am I missing something? (This would probably be my preferred) but I have no idea how to implement.
Lastly I know of plists being heavily used on iOS but these seem more for settings and smaller amounts of data than I want, or am I wrong there too?
Overall which is, or what if I haven’t mentioned, the best format for storing and recalling this kind of information.
Have a look on NSDictionary in the docs – (BOOL)writeToFile:(NSString *)path atomically:(BOOL)flag and – (BOOL)writeToURL:(NSString *)path atomically:(BOOL)flag. Both method and the reading counterpart write a xml format file onto disc. You’ll find the same format in files with the extension .plist, e.g. the preferences file in your apps Library/Preferences folder.