Using Undo Notifications
NSUndoManager regularly posts checkpoint notifications to synchronize the inclusion of undo operations in undo groups. Objects sometimes delay performing changes, for various reasons. This means they may also delay registering undo operations for those changes. Because
NSUndoManager collects individual operations into groups, it must be sure to synchronize its client with the creation of these groups so that operations are entered into the proper undo groups. To this end, whenever an undo manager opens or closes a new undo group (except when it opens a top-level group), it posts an
NSUndoManagerCheckpointNotification so observers can apply their pending undo operations to the group in effect. The undo manager’s client should register itself as an observer for this notification and record undo operations for all pending changes upon receiving it.
NSUndoManager also posts a number of other notifications at specific intervals: when a group is created, when a group is closed, and just before and just after both undo and redo operations.
© 2011 Apple Inc. All Rights Reserved. (Last updated: 2011-06-03)