11 NSUndoManager

Using NSUndoManager, you can add undo capabilities to your applications in a very elegant manner. As objects are added, deleted, and edited, the undo manager keeps track of all actions that must be taken to undo these changes. As you invoke the undo mechanism, the undo manager keeps track of all actions that must be taken to redo those changes. This mechanism works by maintaining two stacks: one for undo and another for redo. The objects on the stacks are instances of NSInvocation, a class that describes a message send: the receiver, method name, and arguments.

This is a pretty heavy topic to cover so early in a book. (Sometimes when we think about undo, our heads start to swim a bit.) However, undo interacts ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide 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.