Interface Builder enables you to connect a custom object to its outlets and to the objects in the user interface that invoke action methods of the custom object. This connection information is stored in the nib file along with the user interface objects, class definitions, and nib resources.
Before you can connect a custom object to objects in the user interface, you must create an instance of the object. (This is not a real instance, but a "proxy" instance representing the connections to the object. The real instance is created when the nib file is loaded.)
The nib file window automatically changes to the Instances display, and an instance of the TempController class (depicted as a cube) appears in the display.
Follow this Interface Builder procedure to connect the TempController custom object to its outlets:
"Control-drag" means to hold down the Control key while dragging the mouse (moving it with the mouse button pressed).
Interface Builder shows the Connections display of its Inspector. The left column of this display lists the outlets defined by TempController.
fahrenheit
outlet.Follow this Interface Builder procedure to connect the action method defined by TempController to the objects that might invoke that method:
Interface Builder shows the Connections display of its Inspector. The left column of this display lists the outlets defined by TempController.
convert()
action.You might first have to click the target item under Outlets to get to the action.
As a convenience to users, you want the insertion point to be in a certain field after the application is launched. For the same reason (convenience), you want users to be able to switch between the fields without having to use the mouse--they should be able to tab between the fields. You can specify this behavior entirely in Interface Builder:
initialFirstResponder
.
nextKeyView
and click Connect.
nextKeyView
and click Connect.What have you just done? You've specified the sequence of responder objects in the user interface that are to receive the focus of keyboard events when users press the Tab key.
You can now test the user interface you've constructed with Interface Builder. Save the nib file and choose Test Interface from the Document menu. Interface Builder goes into test mode and the window and text fields you've just created behave as they would in the final application--except, of course, there is yet no custom behavior.
Notice that the insertion point is initially in the Celsius field. Press the Tab key; note how the insertion point jumps between the fields. Type something into one of the fields, then select it and choose Cut from the Edit menu. Click in the other text field and choose Paste from the Edit menu. These are but a couple of examples of features you get in any application with little or no work on your part.