我如何设置特定的重做动作,就像我在使用时设置撤消动作一样prepareWithInvocationTarget
使用我的方法,重做不起作用(撤消有效)
- (void)removeSmth:(Smth *)smth index:(NSInteger)indexOfSmth {
[self.document.undoManager beginUndoGrouping];
...
[self removeSmth:smth];
[[self.document.undoManager prepareWithInvocationTarget:self] undoInsertSmth:smth index:indexOfSmth];
...
[self.document.undoManager endUndoGrouping];
}
- (void)undoInsertSmth:(Smth *)smth index:(NSUInteger)index {
[self insertSmth:smth index:index];
}