假设我有两个原子对象方法operation1
,operation2
它们将自己的撤消操作注册到undoManager
. 如果我进行 bulk operation3
,它将调用前两个操作并将撤消回调与 分组beginUndoGrouping/endUndoGrouping
,撤消时,NSUndoManager
不会对重做操作分组。如何将NSUndoManager
地图撤消组变为重做组?
示例代码:
- (void)operation3
{
[undoManager beginUndoGrouping];
[self operation1]; // [undoManager setActionName:@"op1"];
[self operation2]; // [undoManager setActionName:@"op2"];
[undoManager endUndoGrouping];
[undoManager setActionName:@"op3"];
// call operation3 -> "Edit - Undo op3" -- OK
// press Command+Z -> "Edit - Redo op1" -- not OK
}