Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Apple > Operating Systems

  • Print
  • + Share This
From the author of Linking the Interface to the Code

Linking the Interface to the Code

Now that the interface is built and the code is written, the next step is to connect the interface to the code. In the Project Navigator, click the MainMenu.xib file to display the main interface window again. While holding down the Control key, click and drag from the App Delegate icon in the UI editor's left sidebar to the text field in the main window (see Figure 14).

Figure 14 Connecting the text field as an outlet of the App Delegate.

When the text field is selected, a contextual menu appears. Choose "textField" (see Figure 15), the property we defined in the AppDelegate.applescript file.

Figure 15 Connecting the text field in the UI to the textField outlet property in the AppDelegate.applescript file.

Next, select the Click Me button in the main window. From the Sent Actions area in the Connections inspector (Command-Option-6), click the radio button to the right of "selector" and drag it to the App Delegate icon in the UI editor's left sidebar (see Figure 16).

Figure 16 Connecting the button to the App Delegate.

Another contextual menu appears; this time it shows the handlers (methods) in the AppDelegate.applescript file. Select "buttonClicked:" (see Figure 17).

Figure 17 Connecting the button in the UI to the buttonClicked handler in the AppDelegate.applescript file.

  • + Share This
  • 🔖 Save To Your Account