我想撤消我的 NSManagedObjectContext 上的保存操作;我一直认为,这就是 NSUndoManager 的用途,但似乎撤消保存操作不起作用......
一个例子:
[[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];
但是插入并没有撤消......有没有办法做到这一点?比如交易?