Simple Bindings Adoption
Last Revision: | Version 1.1, 2014-07-08 Upgrade for Xcode 5.0, OS X 10.9, now uses ARC (Automatic Reference Counting) and properties, document now reads and writes volume setting. (Full Revision History) |
Build Requirements: | Xcode 5.0, OS X 10.9 or later |
Runtime Requirements: | OS X 10.7 or later |
This simple example illustrates the adoption of Cocoa Bindings to manage synchronization of values between models and views.
The example is a simple document-based application. Each document has a window with a text field, slider, and button. The values of the text field and slider represent the volume in a Track object managed by the document. The Mute button sets the volume to zero.
There are three versions of the application:
1. Using target-action to update the track's volume when the user presses Enter in the text field or moves the slider. The user interface is updated programmatically.
2. Programmatically: creating an object controller; binding its content to the track object; and binding the values of the text field and slider to the track's volume. The user interface is updated using bindings.
3. In Interface Builder: creating an object controller; binding its content to the track object; and binding the values of the text field and slider to the track's volume. The user interface is updated using bindings.
Copyright © 2014 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2014-07-08