Undo and Redo

The Application Kit includes a powerful and flexible system to implement undo and redo operations by taking advantage of the Objective-C runtime to record the messages sent to objects and play them back later. Many Application Kit classes including the text management views already implement undo and redo.

Each instance of the NSDocument class optionally includes an instance of NSUndoManager. The NSUndoManager class stores recorded messages and works with the standard Undo and Redo menu items. NSUndoManager is actually part of the Foundation framework because nongraphical applications might include undoable operations. The NSUndoManager class can be used without the NSDocument class and visa versa, but using them together automatically ...

Get Cocoa® Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.