Database Reference
In-Depth Information
CHAPTER 8
OS X: Bindings, KVC, and KVO
Cocoa Bindings provides a lot of the magic behind Core Data. It consists of
a number of APIs and concepts that together allow us to develop our applica-
tions using the Model View Controller paradigm, without requiring a tight
coupling of the three aspects.
Cocoa Bindings allows us to design views, controllers, and models that all
expect data in a specific format, without requiring that we bind them to spe-
cific classes. This means we can use views in multiple places and swap out
controllers and even models without the need for extensive recoding, if any.
In this chapter, we look at some of the key components of Cocoa Bindings
and then delve into the specifics of how Core Data works with those bindings.
The two primary APIs we discuss are Key Value Coding and Key Value
Observing. These APIs are part of the foundation that allows Interface Builder
to function. Between the two of them, they give us a tremendous amount of
flexibility in our design. In addition, Core Data uses these APIs heavily in
order to allow us to focus on the business logic of our applications, as opposed
to the data layer. With the combination of Cocoa Bindings and Core Data,
the amount of code that we need to write, and therefore debug and maintain,
is drastically reduced.
While this chapter is primarily focused on OS X, there are some fundamental
portions that affect both OS X and iOS. Specifically, KVC and KVO are avail-
able on both platforms. While the Cocoa Bindings discussed in depth in this
chapter applies only on OS X, it is highly recommended that iOS developers
become familiar with these technologies as well.
8.1
Key Value Coding
Key Value Coding (KVC) is one of the cornerstones of Cocoa Bindings. KVC
allows us to access the attributes of an object without calling the accessors
 
 
 
Search WWH ::




Custom Search