iPhone – HelloWorld in iphone

This is an HelloWorld example.it will be good to use the latest Xcode version so the performance will be much better.i am using Xcode 4.

There are three types of files,
(i) .h
(ii) .m
(iii) .xib
•      The .h files are interfaces where the implementation will not be provided.
•    .m files are the implementation files.
•    .xib files are the place where we design the user interface for the user.
(i) AppDelegate.h
(ii) AppDelegate.m
(iii) ViewController.h
(iv) ViewController.m
(v) ViewController.xib
•    AppDelegate files are executed first
•    ViewController files contain the code part for view and logic.
STEP 1: Select Xcode and select Create new Xcode Project option.

Step 2: Select Single View Application and click next.

Step 3: Enter the name for the project and specify the simulators like iphone , ipad or universal and click next.

Step 4:  Select the place where you need to store the project and select Create.

Step 5: Select the ViewController.xib file and drag a label and button from object library and place it on the ViewController.xib.

Step 6: Place the mouse over the Label. now right click and drag a line and place it inside the ViewController.h file.

Step 7: Now a window appears. here select Outlet in Connection field and  give a name to your Label.

Step 8: Now repeat step 6 for Button. but the difference is here select Action in Connection  field and give a name to your method. this method will be called when you press that button.

Step 9: Add this code below inside the  Button method in VewController.m. Here the method name is changeLabel() and Label name is labelObject.
labelObject.text=@”HelloWorld iphone”;

Step 10: You made it!! now Run the project.


#import <UIKit/UIKit.h>

@interface ViewController : UIViewController

@property (strong, nonatomic) IBOutlet UILabel *labelObject;

– (IBAction)changeLable:(id)sender;


#import “ViewController.h”

@interface ViewController ()


@implementation ViewController
@synthesize labelObject;

– (void)viewDidLoad
[super viewDidLoad];


– (void)viewDidUnload
[self setLabelObject:nil];
[super viewDidUnload];


– (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);

– (IBAction)changeLabel:(id)sender {
labelObject.text=@”HelloWorld iphone”;



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s