Chapter 18

Key-Value Coding

One idea we keep coming back to is indirection. Many programming techniques are based on indirection, including this whole object-oriented programming business. In this chapter, we’ll look at another indirection mechanism. This is not an Objective-C language feature, but one provided by Cocoa.

So far, we’ve been changing an object’s state directly by calling methods directly or via a property’s dot-notation or by setting instance variables. Key-value coding, affectionately known as KVC to its friends, is a way of changing an object’s state indirectly, by using strings to describe what piece of object state to change. This chapter is all about key-value coding.

Some of the more advanced Cocoa features, like Core Data ...

Get Learn Objective-C on the Mac: For OS X and iOS, Second Edition now with O’Reilly online learning.

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