I have an NSFetchedResultsController
that is fetching results from a managed object context of NSMainQueueConcurrencyType
. I also have another managed object context that shares the same NSPersistentStoreCoordinator
of NSPrivateQueueConcurrencyType
.
All changes are happening on the background context and being propagated to the main context with NSManagedObjectContextDidSaveNotification
.
I had some problems getting certain changes to trigger NSFetchedResultsControllerDelegate
methods as described here, but even after fixing that problem, I find that fetchedObjects
sometimes returns incorrect data with duplicate objects.
The only workaround I can find is to add a performFetch call to controllerDidChangeContent
:
- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller {
[self.tableView endUpdates];
// fetchedObjects is incorrect unless I refetch here...
[controller performFetch:nil];
}
But this seems like an inefficient hack to me. I'm running my entire query every time any data changes. I've also disabled all caching in my NSFetchedResultsController
, for the record.