Getting Started with iOS with UI Elements (Objective-C)

By: Luis A. Sierra


Creating the Hello World iOS App Project

Hello, World! It is the first basic program in any programming language. Let's write the first program in the iOS with Objective-C programming language.

To create and run a hello world program follow the following steps:

Step 1: Open XCode in your system and Create a new XCode project.


Step 2: Select the App and then click on the Next button.


Step 3: Give a name to your project like here we give "helloworld" and then click on next button.



Step 4: Select the project location and then click on the create button. Now the project is created.



Step 5: Now open Main.storyboard file in the project navigator.

OPTION 1: Create the UILabel (with Storyboard)


Step 6: Now go to  View -> Show Library in the xcode menu.


Step 7: Now Add UILabel to the View.


Step 7: Now Setting up a font-size and Choose a color.


Step 8: Connect the IBOutlet

   8.1 Hold down Ctrl, click the UILabel, and drag it inside ViewController.h.


   8.2 In the pop-up window, name the connection msg.


   8.3 Make sure "Connection" is set to Outlet, "Type" is set to UILabel, and click Connect.

   8.4 Your ViewController.h should look like this:


Step 9: Now let go to add the HelloWorld code to the msg UILabel:


OPTION 2: Create the UILabel by code (without Storyboard)

Start from Step 4 and go to ViewController.m and add the code below:


This is useful if you want more control or are working without Storyboard/XIBs.

Step 10: Now let run our app iOS with Objective-C:


Step 11: Now wait to the simulator started 

Post a Comment

Previous Post Next Post