Google Objective-C SDK for iPhone development iPhone Native Application - Button Click Tutorial
Mar 27

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?


35 Responses to “Hello World iPhone Native Application”

  1. Dave Watson Says:

    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!

  2. Hello World iPhone Native Application | Gearfire.com Says:

    [...] 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. … [...]

  3. Pink iPhone » Hello World iPhone Native Application Says:

    [...] 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” [...]

  4.   Get Interface Builder To Work With iPhone SDK by iPhone Dev SDK Says:

    [...] View Tutorial [...]

  5. Gregory PFISTER Says:

    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 ?

  6. Pete Says:

    Awesome! Thanks for the info!

  7. muthuka Says:

    I am working on the other sample to handle tap or touch events through interface builder. No luck so far.

  8. OFred Says:

    And what about the tabbar ? (toolbar)

  9. Hactar Says:

    Anyone know how to use the viewcontroller/navigationcontroller with interface builder.

  10. loda Says:

    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 :-)

  11. Muthu Says:

    You have an example in the site to do it for Cocoa on Mac OS X but not for iPhone yet.

  12. loda Says:

    Muthu,

    I couldn’t find the sample. Could you point me to it?

    thanks,

  13. Dave Says:

    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)

  14. MarkU Says:

    Thanks for providing the basic instruction on how to connect IB to Xcode, especially the code snipped.

  15. muthuka Says:

    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/

  16. Fred Says:

    Thank you! I was really struggling.

  17. Steve Says:

    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.

  18. mp Says:

    Great !. Thanks for the all the info.

  19. ??????? » Blog Archive » links for 2008-03-31 Says:

    [...] Hello World iPhone Native Application | muthu arumugam blog (tags: iphone programming interface builder sdk)     Read More    Post a Comment [...]

  20. Hello World Programm mit Interface Builder und iPhone SDK Beta 2 » Beitrag » iPhone-dev.de Says:

    [...] 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. [...]

  21. mp Says:

    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

  22. Muthu Says:

    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)

  23. mp Says:

    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?….

  24. mp Says:

    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…

  25. mp Says:

    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.

  26. zone12 Says:

    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/

  27. muthu Says:

    Awesome. That’s the link which i missed it while building interaction in my code. Thanks.

  28. mp Says:

    how to draw a simple line on a window without using the IB. ( It seems, IB does not have that feature). any help?

  29. iPhone Development - First Impressions « The Pages o’ Peat Says:

    [...] ? I found an Interface Builder + iPhone tutorial here. Posted by Peat Filed in Apple, Awesome, Banknotes, Coding, Programming, Web Services, iPhone, [...]

  30. mp Says:

    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).

  31. mp Says:

    use exit(0); in the method to take the app to iPhone home page.

  32. iPhone and iTouch Hello World Application : fuXion :: Just learn it! Says:

    [...] 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/ [...]

  33. iphone games music Says:

    Nice blog, i have added it to my favourites, greetings

  34. mma Says:

    I find this blog very interesting, i will be here everyday till now. Greetings

  35. Crear un Hello World para iPhone, con SDK Oficial. « AzagraMac’s Weblog Says:

    [...] Descargar Proyecto Hello World: iPhone HelloWorld Enlace de la Noticia [En Ingles] [...]

Leave a Reply