How to make a Hello World application in Objective C for iPod Touch and iPhone
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Well first welcome to my tutorial on how to make your first application, a hello world in Objective C.
(Remember that this tutorial is beginner but if you don't know what Xcode is, this tutorial is probably not for you.)
Requirement:
Xcode
Part 1
To start, in Xcode click File > New Project and then select View-Based Application. Choose a name (FirstViewApp). Open Classes (Folder) and select FirstViewAppViewController.h. and paste the following IBOutlets, properties and IBAction in the .h file. It will looks like:
Code
@interface FirstViewAppViewController :
UIViewController {
IBOutlet UITextFidel *textField;
IBOutlet UILabel *label;
}
@property (nonatomic, retain) UITextField
*textField;
@property (nonatomic, retain) UILabel
*label;
- (IBAction) clickAction: (id)sender;
@endNow add this to the corresponding .m file:
Code
@implementation FirstViewAppViewController
@synthesize textField, label;
- (void) clickAction: (id) sender{
label.text = textField.text;
//We hide the keyboard on button click.
[textField resignFirstResponder];
}Part 2
Build the project. Now Interface Builder (IB) is aware of the new IBOutlets and IBAction.
Open the Ressources folder and click on FirstViewAppViewController.xib.
It will open IB. Drag a text field in the view designer.
Drag a Label just below the text field.
Now drag a Round Rect button bellow the label.
Click the button and open the insperctor (Use Shift + Command + I). Write a title for the button.
Note that you can edit the text size by clicking the text field then on the IB menu bar, click Font and Show Fonts.
Click FirstViewAppViewController.xib. in the small IB window, named with the xib name, expand the view node.
Now control drag from File's Owner to the UITextField node. A black pop up will appear with the outlet "textField" in it.
Drop the blue line on textField. Do the same or UILabel.
Now, Control + Drag from the UIButton to File's Owner.
Now we can interact with the UI components through code.
Part 3
Build and Run. Type something in the text field and click the button.
If you followed the tutorial correctly the text you entered should appear in the Label.
Thanks for following my tutorial.
--


![[Image: HpRYe.jpg]](https://i.imgur.com/HpRYe.jpg)