Search code examples
iphoneiosuitableviewcore-datareloaddata

Refreshing CoreData Table?


I can refresh any non-CoreData loaded tableView by calling [nameoftableView reloadData];

But when I call this on my CoreData loaded TVC it does not reload the table. Does this work differently?

It does update it contents if I stop and start the app again - so that it reloads the database, so I know it has the updated content in it.

Cheers Jeff


Solution

  • Without details is difficult to know what is going on, but if you use a simple NSFetchRequest I think you need to execute the query and call reloadData again.

    A simple note

    I suggest you to use NSFetchedResultsController when dealing with Core Data and UITableViews. raywenderlich has a tutorial on how to use that class in Core Data. First of all it allows you to deal with a lot of data displayed in a UITableView. In particular, if for the NSFetchRequest you use with, you set a batch size, data will be retrieved in "batches". For example, the first 10. Then if you scroll the other 10 and so on...

    In addition you can deal with data changes (update, insertion or deletion) for free using NSFetchedResultsControllerDelegate class (Reference NSFetchedResultsControllerDelegate).

    Hope it helps.