NSFetchedResultsController fetchedObjects is invalid after changes propagate from the context of a background managed object
I have NSFetchedResultsController
one that retrieves the results from the context of a managed object NSMainQueueConcurrencyType
. I also have another managed object context that has the same ones NSPersistentStoreCoordinator
from NSPrivateQueueConcurrencyType
.
All changes take place in the background context and are propagated to the main context with NSManagedObjectContextDidSaveNotification
.
I was having some problems getting certain changes to run methods NSFetchedResultsControllerDelegate
as described here , but even after fixing this issue, I found myself fetchedObjects
sometimes returning 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 ineffective hack to me. I am executing my entire query every time the data changes. I also disabled all caching in NSFetchedResultsController
for writing.
source to share
No one has answered this question yet
See similar questions:
or similar: