I’m trying to create a save & load module in my app. So the user can save some specific info and then load it at any point in time.
What I’m saving is an array of NSMutableStrings. I’m creating an iPad app so the saved info will be presented in a popover with a TableView.
So, here’s the question. I would like to populate that tableView with my saved arrays, and for that I need to store my arrays somewhere. I’m new to objective-c and programming in general, and would like your advice on what’s the best way of doing that.
Should I use a plist to store those arrays with Keys, so the keys will be the names that the user introduces when saving and also the name of the tableView cells? or maybe a simple NSMutableDictionary will do?
Please advise.
This answer might help you. Using Core Data might be overkill here, and saving to a plist is extremely easy. This is Benoît’s answer from the linked question:
where
rootObjis the object you wish to serialize, in this case, your array/dictionary.Also, if you are going to be read/writing to this data frequently during the course of your app, using a singleton which can make a huge difference performance-wise instead of constantly reading/writing from/to a file. You can load all of your data into the singleton on app-launch and save it upon
applicationWillTerminate.To answer your array/dictionary question, it depends on how you are obtaining your strings and how you want them to be ordered. Sorting an array is extremely easy, as you can see in this answer.