When core data is changed, how to update the table view data?
Using NSXMLParser to get data from an xml file on internet wi开发者_开发问答th an update button to get update database and store it by using xcode template core data. However, when I updated all core data, console can only show right data until I quited the app and run it again. Any way to update all data correctly without quiting the app?
Thanks for that answer. With using Xcode template (Navigation-based Application with core data), fetchedResultsController and managedObjectContext and so on are all included. Yet, every time I changed xml file and run parser to store data again, both my table view and nslog messege come up with a list of wrong data, eg, list of numbers only while my data contains lots of strings. Display comes back to normal only I killed and rerun app again. Any ideas?
Using CoreData the simplest thing to do is to use a NSFetchedResultsController. You can set your view controller to be the delegate for the NSFetchedResultsController, which will give you notifications when your data changes. You can then update your table appropriately.
This tutorial might help: http://www.raywenderlich.com/999/core-data-tutorial-how-to-use-nsfetchedresultscontrolleY
精彩评论