Finally Apple released an initial version of iPhone SDK Beta 2 which has Interface Builder. It’s really cool to create applications. I wanted to put together the first step of creating HelloWorld quickly on it.
- Open XCode
- Create a new Project as “Cocoa Touch Application”
- Provide the project name as “HelloWorld” on your selected folder and Click Save
- Open Interface Builder and Click “Cocoa Touch” tab on the top
- Select Window and Click “Choose”
- Design the UI something like the following:
- Save it as MainWindow under the same folder as HelloWorld
- When it prompts to include it for the build, Choose “HelloWorld” and click Add
- Quit the Interface Builder
- Go back to XCode and edit “HelloWorldAppDelegate.m”
- Replace the content of the method applicationDidFinishLaunching with the following snippet. Save it and Run it.
// Create window
self.window = [[[NSBundle mainBundle] loadNibNamed:@”MainWindow” owner:self options:nil] objectAtIndex:0];
// Show window
[window makeKeyAndVisible];
Download the XCode Project: iPhone - HelloWorld.zip?
Comments (35)
Thanks so much! I’ve been trying to figure out how to actually load my nib, since the documentation is currently non-existent (what do I expect, since the new beta was only just released). I’ll have to give this a try!
[...] cadamson wrote an interesting post today onHere’s a quick excerptFinally Apple released an initial version of iPhone SDK Beta 2 which has Interface Builder. It’s really cool to create applications. I wanted to put together the first step of creating HelloWorld quickly on it. … [...]
[...] Iphone Instylez wrote an interesting post today onHere’s a quick excerptHello World iPhone Native Application iPhone, mac os x, programming 1 Comment » Finally Apple released an initial version of iPhone SDK Beta 2 which has Interface Builder. It’s really cool to create applications. I wanted to put together the first step of creating HelloWorld quickly on it. Open XCode Create a new Project as “Cocoa Touch Application” [...]
[...] View Tutorial [...]
Thanks, but I am lost … I try to connect a button to the controller, like for a Mac OS X cocoa app, but doesn’t seem to work.
Any ideas ?
Awesome! Thanks for the info!
I am working on the other sample to handle tap or touch events through interface builder. No luck so far.
And what about the tabbar ? (toolbar)
Anyone know how to use the viewcontroller/navigationcontroller with interface builder.
how do you configure a button to launch an action with the interface builder? (eg. a button is touched->a label is changed)
I’m new to cocoa and it’s frustrating
You have an example in the site to do it for Cocoa on Mac OS X but not for iPhone yet.
Muthu,
I couldn’t find the sample. Could you point me to it?
thanks,
Thanks! This got me started. My only problem was I had to fix the formatting of the code snippet and replace the quotes around @”MainWindow” (it’s good in the .zip file)
Thanks for providing the basic instruction on how to connect IB to Xcode, especially the code snipped.
For Cocoa program to handle event, please look at the example here at: http://techblog.muthuka.com/index.php/2008/03/21/random-number-generator-in-cocoa-application/
Thank you! I was really struggling.
Saviour, while this is clearly basic stuff, without it you can’t climbing the ladder to build anything. For me XCode and Interface builder are alien technologies (done loads of C, C++, java etc) but it’s always painful getting started and your contribution has helped me a great deal. Thanks.
Great !. Thanks for the all the info.
[...] Hello World iPhone Native Application | muthu arumugam blog (tags: iphone programming interface builder sdk) Read More Post a Comment [...]
[...] in sein Programm einbindet, dem ist jetzt geholfen. Muthu Arumugam veröffentlichte auf seinem Blog ein Hello World Tutorial welches dies in einer Step by Step Anleitung sehr gut demonstriert. [...]
Hey , are NSLog statements getting printed in the xcode console?. when i was using the first SDK beta version,it worked fine. Now i am not seeing any of my NSLog statements in the console (i have the second SDK beta version installed). This happens only for the iPhone application,when i use the same xcode to build a Mac OS application, NSLog statements are getting displayed in the console. there is no issue with th NSLog statement as such ( NSLog(@”test “); )
. any idea?
~mp
In Beta 2 SDK, that’s broken and you can see the log only in Console.app (i read this in apple developer discussions somewhere)
ohh ok…i was wondering w.r.t NSLog statements..thanks Muthu..
Has anyone tried of MVC type sample application so far?.. is it really possible with the current SDK version. any clues?….
i have a text-field (its an IBOutlet of UITextField) on the screen i which accepts some number,i need to take this value into a float variable in my code. any idea which is the class and method used for this purpose. if some one has found already, pls share it…
w.r.t to my earlier post (UITextField).
finally it worked with the following code.
float rate = [rateField.text floatValue];
rateField is a textfield on the screen which is an IBOutlet.
I have written a tutorial on how to make an iPhone app using interface builder with interaction. Have a look: http://zone12.co.uk/iCode/
Awesome. That’s the link which i missed it while building interaction in my code. Thanks.
how to draw a simple line on a window without using the IB. ( It seems, IB does not have that feature). any help?
[...] ? I found an Interface Builder + iPhone tutorial here. Posted by Peat Filed in Apple, Awesome, Banknotes, Coding, Programming, Web Services, iPhone, [...]
hi, can anyone pls guide me which class/method i need to use in the following.
i will have a home button on the navigation bar , pressing the button should lead me to the home page of the iPhone where all the applications will be listed. (Like the black button on the iPhone simulator / iPhone ,outside the screen).
use exit(0); in the method to take the app to iPhone home page.
[...] Here is probably the most simplified way to create a Hello World application for the iPhone or iTouch: http://techblog.muthuka.com/index.php/2008/03/27/hello-world-iphone-native-application/ [...]
Nice blog, i have added it to my favourites, greetings
I find this blog very interesting, i will be here everyday till now. Greetings
[...] Descargar Proyecto Hello World: iPhone HelloWorld Enlace de la Noticia [En Ingles] [...]