8.1. Connecting Cocoa Interfaces
In earlier chapters you learned how to use Xcode to create a Cocoa application shell and use Interface Builder to design its user interface. Those examples stopped short of actually connecting the interface to code, because the details vary between Carbon and Cocoa. In fact Cocoa provides two different complimentary ways of hooking up user interfaces.
Older Cocoa applications and programs with fairly specialized needs may choose to work with the user interface directly. In these cases you are responsible for keeping the controls synchronized with the state if their application. In other words, you must initialize your controls with your application data and you must grab a new value from the controls when they change. This technique is direct and easy to grasp, but it can be hard to work with to create large user interfaces.
In Mac OS X 10.3 Panther, Apple introduced Cocoa Bindings, a new way of connecting Cocoa controls to custom Objective-C objects. Cocoa Bindings let you bind your application's controls to specific pieces of data. When your data changes, Cocoa Bindings will update the control; similarly, when the control changes, Cocoa Bindings will update your data. Cocoa Bindings helps to alleviate some of the tedium of connecting larger interfaces by hand; however, some specialized interfaces may be difficult to convert entirely to Cocoa Bindings.
Modern Cocoa applications use both techniques in their user interface. Fields that naturally ...