Suppose I have two atomic object methods operation1
and operation2
, that register their own undo actions to undoManager
. If I make bulk operation3
, that calls previous two operations and groups undo callbacks with beginUndoGrouping/endUndoGrouping
, when undoing, NSUndoManager
doesn't group redo actions. How to make NSUndoManager
map undo group to redo group?
Sample code:
- (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
}
You must set the action name again during the undo. I think you set only "op1" during the undo.