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 applications 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 specific 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 available on both platforms. While the Cocoa Bindings discussed in depth in this chapter applies only on OS X, I strongly recommend that iOS developers become familiar with these technologies as well.