Connect ConverterController to the Interface

In this section you’ll create an instance of ConverterController and use Interface Builder to connect the controller object’s outlets to objects in the user interface.

Generate an Instance of the Class

As the final step of defining a class in Interface Builder, create an instance of your class and connect its outlets and actions:

  1. Select ConverterController in the Classes window, if it is not already selected.

  2. Choose Instantiate from the Classes menu. The instance will appear in the Instances view, as highlighted in Figure 7.21.

    The ConverterController instance

    Figure 7-21. The ConverterController instance

Connect the Custom Class to the Interface

Now you can connect this ConverterController object to the user interface. By connecting it to specific objects in the interface, you initialize its outlets. ConverterController will use these outlets to get and set values in the interface.

  1. In the Instances display of the nib file window, Control-drag a connection line from the ConverterController instance to the first text field, as shown in Figure 7.22. When the text field is outlined, release the mouse button.

    Connecting the ConverterController instance to a text field

    Figure 7-22. Connecting the ConverterController instance to a text field

  2. Interface Builder brings up the Connections display of the Info window. Select the outlet that ...

Get Learning Cocoa now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.