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.

+3
ios uitableview core-data nsfetchedresultscontroller nsmanagedobjectcontext


source to share


No one has answered this question yet

See similar questions:

nine
Managed Data Object Context Design Guidelines
2
NSFetchedResultsController does not always call didChangeObject: atIndexPath: forChangeType: newIndexPath: for NSFetchedResultsChangeMove

or similar:

28
Master data nested managed object contexts and frequent deadlocks / hangs
21
NSFetchedResultsController does not show updates from other context
8
NSFetchedResultsController calls the controller delegate DidChangeContent multiple times with stale results?
3
NSFetchedResultsController does not fire delegate method after merging updates from background thread
2
How do I avoid the UI freezing while saving the managed object?
0
NSFetchedResultsControllerDelegate not called when the data no longer matches the predicate
0
NSFetchedResultsController - Delegate methods crashes on iPhone OS 3.0, but DOES NOT RAISE 3.1
0
CoreData Multiple NSManagedObjectContext Notification Persistence
0
Changes in child context propagate to another child context (same hierarchy level) without merging
0
how to update my fetchedresultcontroller after change from other contexts



All Articles
Loading...
X
Show
Funny
Dev
Pics