I'm having issues with saving an entity using a UIManagedDocument. I have a NSFetchedResultsController with its context set as the UIManagedDocuments context. I have the controller set up with sections. The user adds an entry to the UIManagedDocuments context and I save the context using: [context save:&error]; and my NSFetchedResultsController updates properly.
If I leave the view that has the NSFetchedResultsController and then return to the view, in which I create a new NSFetchedResultsController with the same UIManagedDocuments context, I get an error back when I call: [fetchedResultsController performFetch:&error];
The error says:
CoreData: error: (NSFetchedResultsController) The fetched object at index has an out of order section name '. Objects must be sorted by section name'
and the fetch fails.
If I wait a while before I return to the view I don't get the error. I know that the save operation is done on the child context and then pushes the changes onto the parent context and I think this has something to do with the problem. Does anyone have a solution?