Performing undo and redo is usually as simple as sending undo
and redo
messages to the NSUndoManager. undo
closes the last open undo group and then applies all the undo operations in that group (recording any undo operations as redo operations instead). redo
likewise applies all the redo operations on the top redo group.
undo
is intended for undoing top-level groups, and should not be used for nested undo groups. If any unclosed,
nested undo groups are on the stack when undo
is invoked, it raises an exception. To undo nested groups, you must
explicitly close the group with an enableUndoRegistration
message, then use undoNestedGroup
to undo it. Note
also that if you turn off automatic grouping by event with setGroupsByEvent:
,
you must explicitly close the current undo group with enableUndoRegistration
before
invoking either undo method.
Last updated: 2009-05-16