Chapter 9. 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 messages that must be sent to undo these changes. As you invoke the undo mechanism, the undo manager keeps track of all messages that must be sent to redo those changes. This mechanism works by utilizing two stacks of NSInvocation objects.

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 with the document architecture. If we tackle this work now, you will see in the next chapter how the document architecture is supposed to work.

NSInvocation

Get Cocoa® Programming for Mac® OS X, Fourth Edition 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.