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