Chapter 6. Using key-value coding and key-value observing
This chapter covers
- Learning key-value coding (KVC)
- Tying KVC to the UI
- Using key-value observing (KVO)
Throughout this book you’ve called getter and setter methods to retrieve or modify attributes of object instance variables. Using a mechanism called key-value coding (KVC), you can manipulate object properties indirectly. With KVC comes the ability to observe changes to a particular key value, which is known as key-value observing (KVO). These two concepts go hand-in-hand and are the building blocks of other Cocoa frameworks, such as Core Data, which we’ll cover in chapter 7.
In this chapter we’ll introduce KVC and KVO and walk you through the process of building a MacRuby application that utilizes these mechanisms. By the end of this chapter you’ll have a good understanding of both concepts, and you’ll be increasing the dynamic functionality of your MacRuby Cocoa applications in no time.