Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 16: Key-Value Coding

Chapter 16

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 and Cocoa Bindings (which we'll not talk about in this book), use KVC as cogs in their fundamental machinery.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint