Cocoa Programming for OS X: The Big Nerd Ranch Guide
by Aaron Hillegass, Adam Preble, Nate Chandler
Adding Undo to RaiseMan
Open the RaiseMan project that you started in Chapter 9. You are going to give users the ability to undo the effects of clicking the Add Employee and Remove buttons, as well as the ability to undo the changes they make to Employee objects in the table. The necessary code will go into your Document class.
Because you have bound the contentArray of the array controller to the employees array of the Document object, the array controller will use key-value coding to add and remove Employee objects. You will take advantage of this to add undo invocations to the undo stack when people are added and removed. To do this, open Document.swift and add the following section to the Document implementation:
// MARK: - Accessors ...