문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top