CoreData: Cancel button doesn't prevent modified entity to save changes
Hello guys. Once again I need your help!
I have the following scenario: I create an Entity of a NSManagedObject the same way that Apple uses in it's CoreDataBooks code sample. This part works fine: If, during editing you press on 'Cancel', the addingContext is set to nil and the changes are discarded, or, if you press 'Save' the addingContext and the mainContext are merged and the changes saved.
Now, when I open the detailView for one of the created entities I press on the 'Edit' button which opens the same modalView as above but passing the current Entity and a new context (named 'editingContext') to it. The detailViewController implements the same delegate method as the rootViewController in the same way. If the the user presses 'Save' it should merge the editingContext and the main one, otherwise it should just set the editingContext to nil and dismiss the modalViewController.
The problem is that, for some reason, the changes are saved anyway, not matter what button I press. I tried to call also the 'undo' or the 'rollback' methods when the 'Cancel' button is pressed, but with no success.
Do you have any idea why this happens?
|