O'Reilly logo

Beginning iOS 5 Application Development by Wei-Meng Lee

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

OUTLETS AND ACTIONS

As you begin to program iOS applications, you need to first understand the concept of outlets and actions. In iOS programming, you use actions and outlets to connect your code to the various views in your UI. Think of actions as event handlers in the traditional object-oriented programming world, and outlets as object references. If you are familiar with traditional programming languages such as Java or C#, this is a concept that requires some time to get used to — not because it is difficult, but because it is a different way of doing things. At the end of this section, you will have a solid understanding of what outlets and actions are in iOS and how to create them, and be on your way to creating great iOS applications.

TRY IT OUT: Creating Outlets and Actions

image

  1. Using Xcode, create a Single View Application (iPhone)project and name it OutletsAndActions. You will also use the project name as the Class Prefix and ensure that you have the Use Automatic Reference Counting option unchecked.
  2. Select the OutletsAndActionsViewController.xib file in order to edit it using Interface Builder. Populate the View window with three views: Label, Text Field, and Round Rect Button. Set the Label with the text “Please enter your name” by double-clicking on it. Set the Round Rect Button with the “OK” string (see Figure 3-1).

    Figure 3-1

  3. In Xcode, modify the OutletsAndActionsViewController.h ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required