In this first iPhone app tutorial you will be introduced to some new tools like xcode, and Interface Builder. You will also learn how to create new view, add controls, and respond to the events. Click on Read more to continue.Introduction
In this tutorial I will give you a brief introduction on how to get started with your first iPhone application. To begin you will need the latest version of the iPhone SDK which you can download it from here. With the SDK you get some tools like Xcode, Interface Builder, iPhone simulator, and many more. The first application is usually called “Hello World” but I have named my first app “Hello Universe” because a revolutionary device calls for a change of name.

Purpose of the “Hello Universe” app
Using the app a user will be able to enter his/her full name and click a button to see a message appear. The message will say “John Doe says Hello Universe!!!”. This app will not only introduce you to some of the tools but will also show you how to use controls, respond to events and create new views. Excited, I am :-)

This is how the app will look like

Creating a new project
Launch Xcode and click on File -> New Project -> Select Application (under iPhone OS) -> select Window-Based Application project template and click on choose.

In the next screen you will be asked to save your project and give it a name. Xcode creates some files for us based on the name of the project, so you want to be careful with the name you provide. I have named my project “HelloUniverse”.

This is how the list of files look like in Xcode.

All the class files are stored under the “Classes” folder, some special files are listed under “Other Sources”, all the view files and resources show up under “Resources”, and any library or frameworks we add to our project are listed under the “Frameworks” folder. It is important that we save all the images, files, databases, and views in the “Resources” folder because all the iPhone apps run in its own sand box; which means they can only access files placed under the resources folder.

How the app is launched
Every C/C++/Java/C# programmer knows about the main method found in main.m file which is present under the “Other Sources” folder. You normally will never have to change this method and all we have to know is that this method is responsible in launching the app. The method applicationDidFinishLaunching method is called when the app is launched on the device or the simulator. The method is defined in “HelloUniverseAppDelegate.m” file which is found under the “Classes” folder.

Interface Builder
Using Interface Builder we can design our application by adding controls or creating additional views. The files that the Interface Builder creates gets saved with a .xib extension and are called nib files. Every project gets one nib file by called which is called “MainWindow.xib” which can be found under “Resources”. An iPhone application has only one window (MainWindow.xib) unlike a desktop application which is created with multiple windows; however, we can create multiple views which are added to the window. Double click on “MainWindow.xib” to launch the Interface Builder, which will open four windows and one of the window will look like this


The above picture shows the contents of the “MainWindow.xib” nib file. Every nib file has atleast two files; File’s Owner and First Responder which cannot be deleted. Every other objects apart from the first two, represents an instance of an object which gets created when the nib file loads. File’s Owner simply shows that it owns the object in the nib file. First Responder tells us which object are we currently interacting with; like the textbox, buttons… The third object which is special to the MainWindow.xib file is called “Hello Universe App Delegate” and this file represents “HelloUniverseAppDelegate” class. Last but not the least the view represents the object which we design in our apps.

Creating a new view
If we had created this project using “View-Based Application” project template then there would have been no need of creating another view from scratch, but where is the fun in that. In Interface Builder create a new view by clicking File -> New -> Select Cocoa Touch -> View and click on choose. Let’s save the view in the project folder by naming it “HelloUniverse” and once we do that IB (Interface Builder) will prompt us to add the view to the current project; click on “Add” and it will show up in Xcode. In Xcode and move your view to the Resources folder.

Creating a view controller
We have a view now let’s create a view controller to manage the view. In Xcode create a new view controller by selecting classes and clicking File -> New File -> Select Cocoa Touch Classes under iPhone OS -> select UIViewController -> click on choose and name your file “HelloUniverseController” without changing the extension. The newly created class inherits from UIViewController which knows how to interact with a view. Now that we have our view and the controller class, there must be some way to connect these two files and we can do it by setting the class property of the File’s Owner. Double click “HelloUniverse.xib” file in Xcode to launch Interface Builder and select File’s Owner -> select Tools -> Identity Inspector and under “Class Identity” category, change the class to “HelloUniverseController”. This is how the Class Identity should look like


Once that is done we need a way to control the view in the nib file from code and this is done by connecting the view instance variable to the view object in the nib. The connection is made using “outlets”. Select Tools -> Connections Inspector create a connection from the view variable to the view in the nib file. Move your mouse over the empty circle to see it change to a plus symbol indicating that a connection can be created. Click on circle and drag your mouse to the view in the nib file and release. As you do this you will see a blue line being created from the circle to the mouse. Once a connection is created, the connections inspector for File’s Owner will look like this


Adding controls to the view
From the screen shot above we require two text boxes, one label, and a button (Round Rect Button). From the library drag and drop the controls to the view and align it as seen in the figure 1.0. After you have added the controls let’s change some of its properties, starting with the text boxes. Select the first text box and open Attributes Inspector by selecting Tools -> Attributes Inspector. Under Placeholder enter “First name”, under “Text Input Traits” change Capitalize property to “Words” and change the Return key property to “Done”. Apply the same settings for the other text box but change the Placeholder to say “Last name”. Select the label and delete its text property, since we do not want the label to say anything until the button is clicked. Double-click the button to edit the title of the button and type in “Click Me”. Save and quit Interface Builder as we have successfully designed our view.

Connecting instance variables to the objects in the view
We still need some way to interact with the controls on the view, in code and this is where outlets help us out. IBOutlet is a special keyword if used with an instance variable, will make the variable appear in Interface Builder. Since IBOutlet makes the variable appear in Interface Builder, using IBAction as a return type for a method will have the opposite effect. Using IBAction we can handle an event triggered by any control placed on the view. Let’s see how this works; open HelloUniverseController.h file in Xcode and type in the following code

//HelloUniverseController.h
@interface HelloUniverseController : UIViewController {

IBOutlet UITextField *txtFirstName;
IBOutlet UITextField *txtLastName;
IBOutlet UILabel *lblMessage;
}

- (IBAction) btnClickMe_Clicked:(id)sender;

@end

//HelloUniverseController.m
- (void)dealloc {
[txtFirstName release];
[txtLastName release];
[lblMessage release];
[super dealloc];
}

All the variables above are marked with IBOutlet and Interface Builder will make these available to itself so proper connections can be made. We also have a method whose return type is IBAction (void); Interface Builder will also make this method available to itself so we can choose which event will call this method. The method also takes a parameter called “sender” which is the object which triggered the event. The variables are released in the dealloc method as shown above. Let’s connect these instance variables to the controls on the view (HelloUniverse) as described earlier. Open Interface Builder by double-clicking HelloUniverse.xib file and select File’s Owner, open Connections Inspector to see all the variables present under Outlets and to create connections.


Let’s hook up the button click event to the “btnClickMe_Clicked” method. Select the button and under the Events list it seems that we do not have a button click event; however, we do have a “Touch Up Inside” event which is raised when the button is touched and released symbolizing a click. With the button selected click the circle next to “Touch Up Inside” and drag your mouse over to File’s Owner and release to have the method name show; simply click on the method name to create a connection.


Handling events
Let’s write some code in btnClickMe_Clicked event to read the first and last name and display a message in the label. This is how the code looks like

//HelloUniverseController.m
- (IBAction) btnClickMe_Clicked:(id)sender {

NSString *FirstName = txtFirstName.text;
NSString *LastName = txtLastName.text;
NSString *Message = nil;

if([FirstName length] == 0 && [LastName length] == 0)
Message = [[NSString alloc] initWithFormat:@"Anonymous says Hello Universe!!!"];
else if ([FirstName length] > 0 && [LastName length] ==0)
Message = [[NSString alloc] initWithFormat:@"%@ says Hello Universe", FirstName];
else if ([FirstName length] == 0 && [LastName length] == 0)
Message = [[NSString alloc] initWithFormat:@"%@ says Hello Universe", LastName];
else
Message = [[NSString alloc] initWithFormat:@"%@ %@ says Hello Universe", FirstName, LastName];

lblMessage.text = Message;

//Release the object
[Message release];
}

The method does few simple things, it finds out the first and last names and figures out what message to display in the label. We also create a temporary variable called “Message” to hold the message which will be displayed in the label. The variable is allocated and initialized by alloc and initWithFormat messages respectively. The variable is released in the end because when working with the iPhone we are responsible of cleaning up the memory. The easiest way to remember when to release objects is; if you create it then you own the object and hence you are responsible of releasing it.

If you click on Build and Go, the view will not be visible because we have not yet added it to the window. Let’s see how we can do that

Adding view to the window
Now we cannot drag the view and add it to the window, so we need another way to add the view as a sub view to the window. We already know that “HelloUniverseController” is the view controller of the view “HelloUniverse” and “HelloUniverseAppDelegate” is the application delegate where the window is made visible in applicationDidFinishLaunching method. It is in that method we will add the view as a sub view to the window. Before we do that, the application delegate (HelloUniverseAppDelegate) needs to know about our view controller. Add the following lines to HelloUniverseAppDelegate.h file to change the file like this

//HelloUniverseAppDelegate.h
@class HelloUniverseController;

@interface HelloUniverseAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
HelloUniverseController *hvController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) HelloUniverseController *hvController;

@end

From the above code we first add a forward class declaration of “HelloUniverseController” because we do not want any circular dependency when we import the header file of “HelloUniverseController” in HelloUniverseAppDelegate.m. A variable and a property of type HelloUniverseController is also declared. The property as you can see is declared with a couple of attributes called “retain” and “nonatomic”. The retain attribute will increase the reference count of the instance variable by one and nonatomic is used because our program is not multi-threaded.

A lot of first time users miss to synthesize the property we declared, so let’s do that now at the top of the HelloUniverseAppDelegate.m file and the code looks like this


//HelloUniverseAppDelegate.m
@implementation HelloUniverseAppDelegate

@synthesize window, hvController;
...

The view is added as a subview to the window in applicationDidFinishLaunching method and this is how the code looks like

//HelloUniverseAppDelegate.m
- (void)applicationDidFinishLaunching:(UIApplication *)application {

HelloUniverseController *hvc = [[HelloUniverseController alloc]
initWithNibName:@"HelloUniverse" bundle:[NSBundle mainBundle]];

self.hvController = hvc;

[hvc release];

[window addSubview:[self.hvController view]];

// Override point for customization after application launch
[window makeKeyAndVisible];
}

The second line shows that we imported the header file of “HelloUniverseController” and we also synthesized the property hvController. In the “olden” days in order to create a property we had to create getter and setter methods which would be something like getHVController and setHVController. The synthesize keyword automatically generates these methods for us. In applicationDidFinishLaunching method we allocate and initialize a temporary variable, assign it to our property, release it, and the view associated with the view controller is added as a sub view to the window. The key thing to remember here is that the view message is passed to the “hvController” which returns the view and is added as sub view to the window. A valid view is returned because we created a connection from the view instance variable to the view in the nib file. The property is finally released in the dealloc method as shown below

//HelloUniverseAppDelegate.m
- (void)dealloc {
[hvController release];
[window release];
[super dealloc];
}

We have always allocated and initialized variables in one single line as seen below, this is usually the accepted way but the same code can be written in a different way as seen below

HelloUniverseController *hvc = [HelloUniverseController alloc];
hvc = [hvc initWithNibName:@"HelloUniverse" bundle:[NSBundle mainBundle]];

Build and go to test your application.

Hiding the keyboard
Wait a minute clicking the “Done” button doesn’t do anything. Ideally we would like to hide the keyboard when the “Done” button is clicked no matter which text box we are currently editing. To hide the keyboard we need to do two things; set the delegate of the keyboard to File’s Owner and implement a method called textFieldShouldReturn in HelloUniverseController.m file. To set the delegate, open Interface Builder by double clicking HelloUniverse.xib, select the first text box and click on Tools -> Connections Inspector. Click and drag your mouse by selecting the empty circle next to delegate under “Outlets” and release your mouse over to File’s Owner. Assign the delegate for the next text box in the same manner.

The method textFieldShouldReturn gets called when the “Done” button is clicked and this is how the code looks like

//HelloUniverseController.m
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {

[theTextField resignFirstResponder];
return YES;
}

The method gets a parameter called sender, which is the object that triggered the event. We will use the same object to which we send the resignResponder message, which will hide the keyboard on the textbox. The boolean “Yes” is returned to tell the sender that the first responder is resigned.

Conclusion
I hope you had fun with this tutorial and feel a little confident in writing your next great iPhone app. Please leave me your comments and let me know what you thought.

Happy Programming,
iPhone SDK Articles

PS: I have re-written this tutorial hoping it would be easier to follow. If you have any questions please do not hesitate to send me an email here and I will be happy to help you out.


Attachments

Suggested Readings

 

149 Responses to First iPhone Application

  1. Anthony says:

    >Thanks a lot for the tutorial! I’m also having issues running into the black screen. It’s happening because I’ve run into this exception:

    2009-02-03 23:54:01.874 HelloUniverse[1971:20b] *** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘-[UIViewController _loadViewFromNibNamed:bundle:] loaded the “HelloView” nib but the view outlet was not set.’

    It looks like this message occurs when the viewcontroller is not hooked up to the view. However I have linked HelloViewController’s view outlet to HelloView many times making sure they are associated. Have you seen this error message before? Any ideas?

    Thanks again for the great write-up,
    Anthony

  2. iPhone SDK Articles says:

    >@Yakshagana You can download the source code here http://sites.google.com/site/iphonesdktutorials/sourcecode/HelloUniverse.zip

  3. Yakshagana says:

    >Is there any way I can download the code of this application? For some reason I cant run though I followed all the steps. Looks like I missed a step or 2.

  4. Anonymous says:

    >Never mind. I looked at the console and noticed that even though I uninstalled the app and quit the simulator my original app was still attempting to run in the background. So after I closed down XCode, the Sim and erased the build folder. Then I was able to rebuild the app and run it successfully in the Simulator from the source code download.
    My one criticism is that the Interface builder connections explanations where a little hard to follow and I have a feeling that that is where my original application went wrong.

    Thank you.

  5. Anonymous says:

    >Very nice tutorial. I know a little tiny bit of Obj-C and have made a few simple applications before but I have been looking into coding for the iPhone and these tutorials are great. My app crashes the iPhone Simulator. It goes into a black screen and then it crashes. I though that I had done something wrong so I downloaded the source code and it did the same thing. I dont know what I could be doing wrong.

    Thanks

  6. iPhone SDK Articles says:

    >@Mark All iPhone applications have one window, where all of our views are placed. Think of the window as the base container. A desktop application has multiple windows, but iPhone application only has one.

    Keyboard disappears by sending the “resignFirstResponder” message. So in the method call “resignFirstResponder” like this

    [keyboardVariable resignFirstResponder];

    File’s Owner is what links the code and the view in Interface Builder. You can create the view in code itself, to avoid configuring the File’s Owner.

    Hope these answers help you. Please let me know if I can be of any help.

    Happy Programming,
    iPhone SDK Articles

  7. iPhone SDK Articles says:

    >@bala I have a tutorial on the Web View object here http://www.iphonesdkarticles.com/2008/08/uiwebview-tutorial.html

    Happy Programming,
    iPhone SDK Articles

  8. iPhone SDK Articles says:

    >@bala It is possible to do it without the IB. All you have to do is inherit from the right class like UIWebView to display a web view on the view.

    Happy Programming,
    iPhone SDK Aricles

  9. Mark says:

    >Jai -

    Great tutorial! Followed it slowly, and was successful on my firs try! A few questions about the application and steps:

    1) Can you explain the “File’s Owner” nomenclature? I don’t understand how this relates to the app.

    2) Why are there 2 views for this application? We worked in the HelloView.xib file for all of the tutorial – what does the app do with MainWindow? Why is it a part of our app if we don’t use it? I understand that it must be there for a reason… and it’s doing something… I just can’t figure it out.

    3) The final step – making the keyboard disappear. I can only get it to disappear on hitting ‘return’ – “click me” doesn’t make it disappear. Did I miss something? How would you make it disappear when pressing the ‘click-me’ button?

    thanks!
    mark

  10. Anonymous says:

    >Thanks for the tutorial. The only troubles I had were some misspellings, the missing * mentioned in another comment, and the fact that when I created another view, since there was no details about the kind of view, I created a Cocoa one instead of a Cocoa touch, (it was the one selected by default), which gave me a different set of controls, and at the end I was not able to connect it with the controller. It took me some time to realize why and restart the view of the correct type.

  11. Anonymous says:

    >Thanks for the tutorial. The only troubles I had were some misspellings, the missing * mentioned in another comment, and the fact that when I created another view, since there was no details about the kind of view, I created a Cocoa one instead of a Cocoa touch, (it was the one selected by default), which gave me a different set of controls, and at the end I was not able to connect it with the controller. It took me some time to realize why and restart the view of the correct type.

  12. ohgfx says:

    >great tutorial man.. easy to follow. I also would recommend the full screen shots on the same page so that you dont go back and forth all the time. Other than that it’s great.
    thanks a lot

  13. bala says:

    >one more help i need, any one can help me to develop a simple web browser for iphone…,

    pls. help me to do a simple web browser without using interface builder/ or using with interface builder.

    thank u lot…iphone SDK articles…

  14. bala says:

    >hi thanks 4 ur reply…

    i got that code is now working , i dont know what i corected in the code. thanks for this nice article….

    i have one more doubt, is it posible to do the first iphone application without using the interface builder? if yes mean, help me to do, i say thanks in advance 4 ur help…

  15. iPhone SDK Articles says:

    >@Agustin sorry about the trouble, can you send me an email and I will be able to help you.

    Happy Programming,
    iPhone SDK Articles

  16. iPhone SDK Articles says:

    >@bala can you email me the source code and I will be able to help you better.

    Happy Programming,
    iPhone SDK Articles

  17. bala says:

    >hi first i wish to say thanks 4 this nice article.
    i completed successfully, but i get an empty black screen when i build this application, after few seconds it terminated with__TERMINATING__DUE_TO_UNCAUGHT_EXCEPTION__. pls. help me to run first application.

    thanks 4 ur guidance…

  18. bala says:

    >hi i got this code work. but it display only a black screen in my simulator. why i dont know.. pls help me to get this application work. thanks:)

  19. Agustin says:

    >JAI,

    I did everything but when pressing Build and Go I get a black screen.

    Any idea why?

    Thanks

  20. GiantNinjaRobot says:

    >To Sam: It looks like you’ve got a curly brace in their prematurely

    @synthesize txtFirstName, txtLastName, lblMessage, sFirstName, sLastName;
    - (IBAction) displayMessage:(id)sender {

    //Get the first/last name and store it in the varialble.
    self.sFirstName = txtFirstName.text;
    self.sLastName = txtLastName.text;
    }

    //Declare a temp variable.
    NSString *sTemp = nil;

  21. Anonymous says:

    >Hi,

    Is this tutorial still compatible with the latest iPhone SDK? I’m using Interface Builder v3.1.2 and worked up to the point of naming the first text field but I can’t see any of the following options…

    Under Text Input Traits select Words for capitalize, Name Type Phone Pad for Type and Done for return key. Also select “Clear Context before Drawing” under view. This will clear the text before rewriting. Apply the same settings for the second text field as well but enter “Last Name” for placeholder.

    Are these supposed to be within the same inspector?

    Thanks,

  22. Sam Rose says:

    >Does anyone else only have the numeric keyboard showing? I don’t get alpha.

  23. iPhone SDK Articles says:

    >@dagrt Regarding first point, there is nothing wrong with your code and second I think it’s a matter of choice but yes if your view is complex then you are better of creating the view in Xcoce.

  24. iPhone SDK Articles says:

    >@John,

    Don’t know why the simulator would be crashing, can you email me your code and I will be happy to take a look.

    Happy Programming,
    iPhone SDK Articles

  25. iPhone SDK Articles says:

    >@Sam can you email me your code and I will be happy to take a look at it.

    Happy Programming,
    iPhone SDK Articles

  26. iPhone SDK Articles says:

    >You should be able to drag and drop teh file in XCode

  27. iPhone SDK Articles says:

    >@Chase I guess you do not have the iPhone SDK installed, you can get it from here

    http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_for_iphone_os_2.2__9m2621__final/iphone_sdk_for_iphone_os_2.2_9m2621_final.dmg

    Happy Programming,
    iPhone SDK Articles

  28. Anonymous says:

    >Hi. My HelloViewController appears under the File Owner’s in the MainWindow nib file. I don’t know why. Any suggestions to move it to the HelloView.xib ?

    Thank you for your nice tutorials !

    Humberto

  29. Chase says:

    >When I try to create a project using Xcode, there is no option to create a Window based project. Can you please help?

  30. Sam says:

    >Made the same mistake as gishdog… with an incomplete type forgetting the * before the variable. Works now… All is working except one darn syntax error 'before' if…. I can't find it and it's killing me… any help here would be appreciated.

    In the HelloViewController.m

    ————
    #import "HelloViewController.h"

    @implementation HelloViewController

    @synthesize txtFirstName, txtLastName, lblMessage, sFirstName, sLastName;
    - (IBAction) displayMessage:(id)sender {

    //Get the first/last name and store it in the varialble.
    self.sFirstName = txtFirstName.text;
    self.sLastName = txtLastName.text;
    }

    //Declare a temp variable.
    NSString *sTemp = nil;

    //If firstname is empty and last name is not
    if([self.sFirstName length] == 0 && [self.sLastName length] != 0) {

  31. John says:

    >Wow. Amazing tutorial!

    I want to second and re-quote what was said earlier:

    "When creating the view in the Interface Builder, make sure to create the "Cocoa Touch > View" and NOT the "Cocoa > View". Those are 2 difference View objects with the latter seeming to be the one causing people not seeing the HelloViewController in the drop down menu."

  32. Jong-Hyun B says:

    >Nice Tutorial! Thank you. I made the same mistake as some others. I used Cocoa–>view instead of Cocoa Touch. So I deleted HelloView and made new one with Cocoa–>view. Now when I build and go the simulator crashes… any comments? BTW I am not getting any errors or warnings. Thanks!

  33. Jeroen says:

    >krammark23 – thanks for that info, indeed I added the wrong view as well!

  34. Sam Dutton says:

    >Very helpful — thanks for all your work!

    A few random comments below, some of which have already been made.

    …………………

    - PNGs or GIFs might work better for the screenshots than JPEGs

    - Inline screenshots might be better full-size (I’m pretty sure you can do this in Blogger)

    - I think you should emphasise that Cocoa Touch, not Cocoa should be selected for the project — both when the project is created and when building HelloView.xib

    - ‘Also we have three properties to hold the text fileds’ should be ‘… fields’

    - viewcontroller should be viewController throughout

    - This screenshot should have an asterisk before viewcontroller: http://bp2.blogger.com/_ph0BNaSqIwI/SG1-XoBB5GI/AAAAAAAAAlk/CBp4-cPqoxA/s1600-h/HeaderDelegateFinal.jpg

    - “Next to the view you see an empty circle, click the circle and drag it over to the view and release … To do this click on view and select Connections Inspector, here we will see all our variables defined and it will look something like below” — I think this is a bit unclear and (as I remember) you need to click on File’s Owner to see the stuff you’re referring to

    - “To do this select the view and its connection inspector. There will be event called ‘Touch Up Inside’ which is the button click event”: need to specify that the txtFirstName text field needs to be selected.

    - In general, I think the references to ‘view’ could be clearer, i.e. do you mean the View window, or the View icon in Interface Builder, or …

    ………………..

    Thanks again.

    Sam

  35. xlphs says:

    >Thank you very much for writing this tutorial, it helped me a lot.

  36. Funbit says:

    >Thanks for the tutorial, really helpful

  37. dagrt says:

    >A Question to applicationDidFinishLaunching method

    Why can’t i assign the new viewController object directly to the viewController pointer, like this:

    self.viewController = [[HelloViewController alloc]initWithNibName:@”HelloView” bundle:[NSBundle mainBundle]]

    instead of creating the new HelloViewController pointer *vController ?

    2.Question
    I have read in many forums that creating views and viewControllers should created rather programmatically in Xcode than in Interface Builder.
    Is this true?

  38. Prem says:

    >Very good Tutorial. It helped me a lot.

  39. eric says:

    >I tried and tried but was unable to get this program working. The errors were all in the delegate.m file.

    A good tutorial overall but I just couldn’t get the thing working. I even copied your source code directly and checked all of my connections.. better luck next time I guess..

  40. krammark23 says:

    >A quick update and something for tom, matt and avl concerning the issue of not being able to see the HelloViewController as an option in the class drop down in the Inspector.

    When creating the view in the Interface Builder, make sure to create the "Cocoa Touch > View" and NOT the "Cocoa > View". Those are 2 difference View objects with the latter seeming to be the one causing people not seeing the HelloViewController in the drop down menu.

    I hope that helps.

    And kudos on the tutorial! It was great :) .

  41. Anonymous says:

    >A Well guided tutorial for the beginners..!!

    Thanx for ur work..!!

  42. Anonymous says:

    >I also ran into the issues of not seeing the Text Input Traits, iphone simulator crashing, not finding the HelloViewController class. The problems was that when I created the HelloView nib file I accidently created a Cocoa View rather than a Cocoa Touch View. By correctly creating the Cocoa Touch View all my problems were solved

  43. Anonymous says:

    >I’m having the same problem as one of the anonymous posters, where I get an uncaught exception when I try to run the app. It fails on the [window addSubview:[viewController view] line. Did you resolve this Anonymous?

  44. Daniel says:

    >Fantastic tutorial, didn’t know C or Objective-C, and had been really frustrated trying to sift through the Docs for simple things like this program does! finally broke through the wall and got this running after some troubleshooting with some help from the comment section. The case sensitivity of Objective-C was unknown to me, and I goofed up the viewController once or twice as viewcontroller.

    The interface builder is still a little mystifying, but I’m looking forward to further tutorials to help with that.

    I liked your images of the code instead of letting us copy-and-paste, as this forced me to slow down and read what I was typing in, along with your excellent commenting!

    Great job!

  45. andybiggs says:

    >This is a great tutorial. Coming from a ActionScript background I found the speed of this tutorial perfect for learning. Thanks. I would also recommend reading this page if you are not familiar with objective-c.

    http://developer.apple.com/iphone/gettingstarted/docs/objectivecprimer.action

  46. Anonymous says:

    >Hi, I am a total beginner in programming and find this tutorial great, although there are parts I don’t understand:

    Why do you use a temp variable in the viewcontroller.m file when you could directly play with txtFirstName.text and lblMessage.txt?

    Maybe stupid question, but I managed to get the program working without so I am wondering what is the advantage of such a temp variable?

    Very good tutorial thank you!

  47. Sambasivarao says:

    >Thank you,
    NIce tutorial.
    keep posting new tutorials like this.
    I tried in so many places to get a example to see events, but i didn’t got. This is the tutorial helped me.

  48. Anonymous says:

    >Thanks for the good work. I’m from the VBA/VB/.NET world. Does anyone know why it takes so many lines of code to accomplish this hello world task while in VB or Java it would only take about one line?

    Is there a possibility that Apple will change the language to something a little easier?

    Hopefully, I’m just getting over the learning hump and will find the development a lot easier.

    Kind comments please.

  49. mozz1e says:

    >UITextFieldDelegate declaration is not complete. Could you, please, show the rest of it?

  50. iPhone SDK Articles says:

    >To Nils,

    Yes sFirstName and sLastName should have been released in the dealloc method.

    I will update the code and the screenshot as soon as possible.

    Thanks,
    iPhone SDK Articles