I'm having issues with my NSFetchedResultsController, which seem to be fixed by turning IncludesPendingChanges on, and this worries me. (I've found this to not be true, including pending changes does not help.)
What happens is that my Fetched Results Controller correctly fetches and displays my objects on a full API refresh. Stepping through, I have confirmed that this full API refresh's temporary context is saved and merged without error.
However, if I then return to a view which does this same fetch request from a different navigation flow, only one partially complete object is returned and displayed, rather than the complete set of objects. If I then do a full API Refresh at this point, the refresh displays the correct objects.
I believe my issue may be that mergeChangesFromContextDidSaveNotification is not propagating to the main context, but from my logs and stepping through, it seems to me that it is saving correctly. I'm not sure where to go from here. While IncludesPendingChanges fixes the symptom, I don't believe it fixes the underlying issue.
As some added information, I'm using this framework for my Core Data Management: https://github.com/vokalinteractive/CoreDataManager-iOS
I am turning on includesPendingChanges by adding on line 156 of VIFetchedResultsController.m
[fetchRequest setIncludesPendingChanges:YES]
Edit Whatever fluke caused me to believe includesPendingChanges to YES fixed the problem is no longer present. Turns out this project had some seriously hairy memory management, and after spending all day cleaning that up, I'm still not closer to making this work. Still at the same point though, it looks like the changes are not propagating to the main datastore, or aren't sticking.
As a hint, like I mentioned in my comment below, even when I specify "includePendingChanges:YES", Logging out my fetched objects with:
[self.fetchedResultsController.fetchedObjects description]
ends with "includesPendingChanges: NO". Any idea what can cause this?
Perhaps you got it the wrong way round. The default of includesPendingChanges is YES, as this is the behavior you usually want. That your UI updates getting corrupted is sort of expected.
Setting this attribute to NO is really just meant to facilitate fetches with NSDictionaryResultType, especially when including simple aggregations that can be dealt with on the database level.
I suspect this is by no means an error by you, but a possible flaw of the framework you are using. Anyway, what you identify as an issue, is really just expected behavior.
See the two short paragraphs in the documentation where this is explained quite well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With