11. Key-Value Coding

A lot of code in a typical program is involved with accessing and modifying aspects of an object’s state.

The key-value coding (KVC) mechanism is intended to provide an abstract interface for setting and getting properties on objects. It is combined with the key-value observing (KVO) mechanism, which provides an abstract way of observing changes in a particular property of another object.

KVC lets you interact with every object as if it were a dictionary. You use the same mechanism for reading and writing properties, irrespective of how they are stored. The main advantage is that it eliminates a lot of the need to write custom controller classes to fit model objects to views.

A view class generally needs to get and set properties ...

Get Objective-C Phrase Book, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.