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

Key-Value Coding and To-Many Relationships

In RaiseMan the user will want to be able to undo and redo adding and removing employees. To do this, you will need to execute code which registers the inverse action with the undo manager when employees are added or removed. Since the NSArrayController handles adding and removing Employee objects to and from the employees array, you will not simply be able to execute this code when Document changes the employees array – Document is not changing employees, the NSArrayController is!

Instead, you will need to hook into the key-value coding mechanism that the NSArrayController is leveraging to add and remove employees. KVC defines a number of optional methods by convention which you can implement ...

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