I have a very peculiar.. issue happening with my NSFetchedResultsController.
My setup is using Magical Record, I have a child with the parent set as MR_defaultContext
([NSManagedObjectContext MR_contextWithParent:[NSManagedObjectContext MR_defaultContext]]
).
I create a nested context using the first view controller's managedObjectContext
as the parent, use that for the next page, which is modal. This next page executes a fetch with a predicate, simple, finding all the entities in a to-many relationship.
Now, if I do not save the inserted entities prior to pushing to the next modal page, the fetch is correct. But.. if I save with [self.managedObjectContext MR_saveOnlySelfWithCompletion]
and then push, the fetch is sometimes correct, sometimes (most times) random and incorrect. For example there are 5 entities
it should be fetching, but it fetches 1, 3, 4, sometimes none. Very odd!
Even more odd is I keep the number of entities as a variable in the modal page, which shows 5 correctly. Always. And if I print out the parent entity of the to-many relationship, it does have all 5 relationships set (and the inverse is set correctly as well).
I have read about fetching the permanent IDS before saving, but that did not make a difference.
Anyone know what is going on?