How the NSUndoManager Works
Suppose that the user opens a new RaiseMan document and makes three edits:
-
Inserts a new record
-
Changes the name from
New Employee
toJohn Locke
-
Changes the raise from 5 to 20
To support undo, as each edit is performed your controller will add an invocation that would undo that edit to the undo stack. For the sake of simplifying the prose, let’s say, “The inverse of the edit gets added to the undo stack.”
Figure 11.1 shows what the undo stack would look like after these three edits.
Figure 11.1 The undo stack
If the user now chooses the Undo menu item, the first invocation is taken ...
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.