Creating an Outlet Connection

To enable your code to send messages to a user interface object (telling a label to display a text string, for example, or telling a button to appear or disappear), create a connection from the user interface object to an outlet in your code.

To create an outlet connection
  1. Select a storyboard or xib file in the project navigator.

    The file’s contents open in Interface Builder.

  2. In Interface Builder, select the user interface object that will receive the messages.

    The user interface object can be a control or any other object defined in your storyboard of xib file, such as a label, progress indicator, or map view. You can select the object either by clicking it in the outline view or on the canvas. If the outline view doesn’t appear, display it by clicking the Show Document Outline (../art/DockViewControl_2x.png) control in the lower-left corner of the canvas. Select a control from the list of nested objects.

  3. Choose View > Assistant Editor > Show Assistant Editor.

  4. In the assistant editor, use the jump bar to select the implementation file of the object that will send the messages.

    The implementation file APAViewController.m is selected in the jump bar below.

  5. Control-drag from the object in Interface Builder to the implementation file in the assistant editor.

    Xcode indicates where you can insert an outlet declaration in your code.

  6. Release the Control-drag.

    The assistant editor displays a Connection menu.

  7. Choose Outlet from the Connection menu.

  8. Type the name of the new outlet and click Connect.


    Interface Builder adds the declaration for the outlet to the class. (Outlets are defined as IBOutlet properties. The IBOutlet keyword tells Xcode that this property can be connected to your storyboard or xib file.)

Related Articles