lundi 31 août 2015

How to save user preferences in Core Data?

I am using Core Data to save my data. I preloaded the data from a .csv file. I have an entity named places, with an attribute isFavorite. I am populating the data in UITableViewController. TableViewCell consists of some labels and a button. When the user taps the button the value of isFavorite changes from false to true and vice-versa. I want to show the list of favorite places of the user in a separate tableView. Only those places are shown in favorite tab whose isFavorite value is true.

The problem I am facing is, when the value of isFavorite changes on the click of the button say from false to true and the user closes the app. Upon relaunch the isFavorite value changes back to the one that is saved in the .csv file. How can I save the user changes? So that the favorite places remain in the favorite list.

I read a few articles about NSUserDefaults but couldn't understand properly. If anyone can help me considering my app's scenario, would be appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire