O'Reilly logo

Learn Objective-C on the Mac: For OS X and iOS, Second Edition by Scott Knaster, Waqar Malik, Mark Dalrymple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required