O'Reilly logo

Cocoa Programming for OS X: The Big Nerd Ranch Guide by Aaron Hillegass, Adam Preble, Nate Chandler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

 ​ ​ ​ ​/​/​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required