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 ...

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.