Key-Value Observing

You’ve now seen how key-value coding works, both for simple properties and to-one relationships on the one hand, and for collection properties and to-many relationships. Key-value observing (KVO), on the other hand, allows you to be informed when an object’s properties are changed, whether by KVC or by direct property access.

You saw in Chapter 8 how bindings rely on KVO: objects bound to a key are automatically added as observers of that key and are then notified whenever its value changes. To enable undo capabilities for edits, you will need to add an observer manually. In particular, you want your document object to be an observer for the keys raise and name for all the Employee objects in its employees array. ...

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.