Skip to content

Greetings: Prepare the Project

Application Design

This app is a simple Hello World clone where the user enters the greeting word and the application then displays something along the lines of Greetings Earthling. In order to do that we need the following:

  • A label that displays the greeting
  • An input field that lets the user enter the greeting word
  • A button that executes the greeting
  • A button that clears any text in the label or input field

Prepare Backend

In our code we need two references to an object on the UI: the label and input field which are called Outlet and have the data type IBOutlet and two methods (when a button is pressed) the UI can call called Action which the data type and I think you guessed it already IBAction.

Now one side (UI or code) has to define these references and here we define them on both sides. First let us define one Outlet and one Action on the code side. These definitions are made in the header of the appropriate View Controller which in our case is the iGreetingsViewController.h already created for us by the template. The Outlets are defined within the body of the interface and the Action method is defined between the Interface and End tag of the header. This would look like this:


#import <UIKit/UIKit.h>
@interface iGreetingsViewController : UIViewController {
        IBOutlet UILabel *greetLabel;
- (IBAction) greetMe: (id) sender;

Before going any further please make sure you saved your changes even though XCode will ask you anyhow before leaving the editor.