How to restart request using NSFetchedResultsController

I am finishing my Core Data tutorial and it suggests trying to convert it to NSFetchedResultsController. So I have this so that I can query existing data, but when I add a row at the beginning, tableView: cellForRowAtIndexPath calls NSFetchedResultsController.objectAtIndexPath, but it still returns the old null object instead of the new one. Is there something I need to do to clear this data?

0


a source to share


3 answers


Have you set up your view controller as a getter delegate for the desired result and implemented the NSFetchedResultsControllerDelegate protocol ? If so, you won't need to fetch again, the selected results controller will call the delegate methods in response to the changes.



(Note, however, take a look at the NSFetchedResultsController documentation regarding implementing data source methods as a table.)

+2


a source


No one has answered yet, so I'll add my guess. It looks like this link might make a difference. Calling one of these two methods is supposed to get the update for you:

-[NSManagedObjectContext processPendingChanges]
-[NSManagedObjectContext save] 

      



The documentation for theNSManagedObjectContext

.

+2


a source


The link indicated Naaf. It turns out that after doing the save I needed to call again - [NSFetchedResultsController Execute Fetch].

+2


a source







All Articles