iPhone Hello World (In 3 lines)
February 6th, 2009I’m a big fan of simple, short tutorials that do what you need quickly. Here is a simple iPhone hello world tutorial with 3 steps and 3 lines of code. Download the source code
- Create a new iPhone project of the “View-Based Application” type. ( Helper Image )
-
Open HelloWorldViewController.m in the “Classes” folder, uncomment the ViewDidLoad method on line #35 and add this code to it:( Helper Image )
1 2 3 4 5 6
- (void)viewDidLoad { [super viewDidLoad]; UILabel *helloLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 30, 100, 30)]; [self.view addSubview:helloLabel]; helloLabel.text = @"Hello World"; } - Hit the “Build and Go” button and watch the magic.(or select Buld->Build and Go)
February 6th, 2009 at 1:39 pm
[...] UPDATE: This tutorial no longer works with the latest iPhone sdk. I recommend this tutorial instead: http://icodeblog.com/2008/07/26/iphone-programming-tutorial-hello-world/ [...]
July 20th, 2009 at 11:36 am
Nice Thanks! Works for me…. using iphone 3.0 sim
July 23rd, 2009 at 4:03 pm
Thanks! That’s exactly what a hello, world should be. Simplest program, so complete beginners can get started.
Took me longer to google the tutorial than to get it working.
Great!
September 22nd, 2009 at 9:01 am
Doesn’t get any easier than this. Thanks!
January 8th, 2010 at 6:24 pm
excellent jump start thanku!