PDA

View Full Version : Saving NSUserDefaults into a database?




nottooshabby
Feb 20, 2009, 02:32 PM
My app already uses NSUserdefaults to store user input so that it is retained when they return to my app. Since I already have all the code in place to update the NSUserdefaults when textfields are edited and reload the values into the textfields when the user returns to the program.

Now I have people requesting that I add the ability to store multiple sets of values that can be retreived. Since I didn't originally develop my app to have a database, the idea I am wondering about is can I transfer the NSUserDefaults to a database when a user presses a save button? I assume I could use SQL, but it's only about 30 values and let's say people would want 20 or 30 records at the most. Is SQL the best bet for this? I store the values in NSUserdefaults as NSStrings. I envision copying the NSUserDefaults to the database when the user presses save along with prompting them for a name to use for retreival. When the user wants to retreive a set of values they are copied from the database back into the NSUserDefaults.

Is this a good plan?