Question

I have an iPhone program with a table view. The table view gets its data from a NSMutable Array. I want people to be able to add data to that table, i.e add objects to that array. Using addObject and reloadData, I am able to add objects to the array, and reload the table view so that the newly added data is also displayed. However, once I re-launch the app, the newly added data is missing. My question is what is the best way to store the array in the iPhone so that at re launch i can populate the table with the user added data?

Thanks

Was it helpful?

Solution

I think these are your options.

1) NSUserDefaults

If you just want to store a single array information you can use NSUserDefaults one of the easiest method of storing data.A good tutorial here.

PS : Never use NSUserDefault for saving sensitive information, like login credentials. For that use KeyChain services.A simple tutorial explaining the usage here.

2) Core Data

If you have a large set of data and looking for a database style storage, then you should look at core data. Core data is a high level API written over lower SQLite concepts and is very good. A good tutorial here and here

3) SQLite

If you want to use database using old fashioned way (writing queries) you can use sqlite directly on iPhone. You could get good information from here, here and from this SO question.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top