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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access