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