NSManagedObjectContext: cancel save operation?

I would like to cancel the save operation in my NSManagedObjectContext; I always thought for NSUndoManager, but it seems that canceling the save operation does not work ...

Example:

[[NSManagedObjectContext MR_contextForCurrentThread] setUndoManager:[NSUndoManager new]];
[[NSManagedObjectContext MR_contextForCurrentThread].undoManager beginUndoGrouping];
MyDataObject *mdo = [MyDataObject MR_createInContext:[NSManagedObjectContext MR_contextForCurrentThread]];
mdo.name = @"...";
[[NSManagedObjectContext MR_contextForCurrentThread] save:nil];
[[NSManagedObjectContext MR_contextForCurrentThread].undoManager endUndoGrouping];
[[NSManagedObjectContext MR_contextForCurrentThread].undoManager undo];

But the insert is not canceled ... is there no way to achieve this? How is the transaction?

+3
source share
1 answer

Could you use the context associated with the child managed object to make your save (which pushes it to the parent, but does not touch the file on disk), and then roll back the parent if you want to cancel it?

, save , , rollback - . , , , .

, save ?

+4

All Articles