Who Should Read This Document
Organization of This Document
See Also
Cocoa bindings is a collection of technologies you can use in your applications to fully implement a Model-View-Controller paradigm where models encapsulate application data, views display and edit that data, and controllers mediate between the two. Cocoa bindings reduces the code dependencies between models, views and controllers, supports multiple ways of viewing your data, and automatically synchronizes views when models change. Cocoa bindings provides extensible controllers, protocols for models and views to adopt, and additions to classes in Foundation and the Application Kit. You can eliminate most of your glue code by using bindings available in Interface Builder to connect controllers with models and views.
Cocoa bindings is ideal for developers writing new applications who have some familiarity with Cocoa, and for developers of existing applications who want to simply clean up or eliminate their existing glue code. In most cases, Cocoa bindings can be used to replace traditional Cocoa mechanisms such as target-action, delegation, and some data source protocols. However, great care has been taken to ensure that both approaches can be used side by side within the same application.
This document assumes that you have read Key-Value Coding Programming Guide, Key-Value Observing Programming Guide and Value Transformer Programming Guide.
Important: Cocoa bindings is available to Cocoa Objective-C applications running Mac OS X version 10.3 and later.
The following articles cover key concepts in understanding how Cocoa bindings works:
“What Are Cocoa Bindings?” describes the advantages that Cocoa bindings offers developers; provides a brief summary of how they work; and what design patterns you should use to adopt the technology.
“How Do Bindings Work?” describes in detail the technologies supporting Cocoa bindings and how they interact.
“User Defaults and Bindings” describes the role of the NSUserDefaultsController and how it works with NSUserDefaults.
“Providing Controller Content” describes how to set and modify the content of NSObjectController and its subclasses.
“Working With a Controller’s Selection” describes how to get a controller’s selection and change the current selection.
“Bindings Message Flow” illustrates the flow of messages between model, view and controller objects in a bindings application.
These articles contain tasks that teach you how to use Cocoa bindings:
“Creating a Master-Detail Interface” explains how to implement a basic master-detail interface where a table view is used in the master interface to display a collection of objects, and other views used in the detail interface to display the selected object in the collection.
“Displaying Images Using Bindings” describes the various options when displaying images in columns and contains an example of a custom value transformer.
“Implementing To-One Relationships Using Pop-Up Menus” explains how to implement editable to-one relationship as pop-up menus.
“Filtering Using a Custom Array Controller” explains how to add a search field to the master interface to filter the objects it displays.
“Controller Key-Value Observing Compliance” details the properties for which the controller classes provide key-value observing change notifications.
“Troubleshooting Cocoa Bindings” describes a number of common problems encountered with Cocoa bindings applications and provides methods for correcting the issues.
There are other technologies, not fully covered in this topic, that are fundamental to how bindings work. You may want to read these topics if you want a better understanding of the underpinnings of Cocoa bindings, or if you want to use these technologies independent from bindings. For example, this topic does not explain how to use the methods defined in the key-value observing protocol. Refer to these documents for more details:
Cocoa Application Tutorial Using Bindings takes you through the steps of building the familiar Currency Converter application using Cocoa bindings.
Cocoa Bindings Reference enumerates the classes that support Cocoa bindings and provides descriptions of the bindings for each class, along with the supported options and placeholders.
Key-Value Coding Programming Guide covers all the features of the key-value coding protocol that allows objects to indirectly access the properties of other objects.
Key-Value Observing Programming Guide covers all the features of the key-value observing protocol that allows objects to observe changes in other objects.
Value Transformer Programming Guide describes how to use value transformers to convert values from one type to another.
Sort Descriptor Programming Topics describes how to use sort descriptors that specify how collections are sorted.
© 2003, 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-03-08)