TWEAK THE CODE
The .h file contains “declarations” or statements that tell Xcode what kind of objects and what actions are being used in the project. They must be listed (declared) here in order for them to be recognized by the application when it runs.
The .m file or the implementation file is where your program instructions or actions are written in complete detail as to what you want your application to do. In this case, we are programming the objects: the button and the label.
- Select the .h file to open it in the Xcode window. You should see the code in bottom right pane of the Xcode window and the file name in the top right pane of the same window.
- Select the green text that says “/* Specify a superclass . . . */” and in its place type “UIView“ Be careful not to erase the opening curly bracket that follows the green text.
- After the closing curly bracket, and above the code that contains “IBAction” type: @property (nonatomic, retain) UILabel *mainText;
- Then select File => Save from the Xcode menu.
- Now we will edit the .m file. Select the .m file to Open open it and right underneath the line with – (IBAction)showText type: mainText.text = @”Hello World”;
- Click File => Save
- To finish your project, click “Build and Go” from the Xcode menu. Your finished app should open in the simulator.
Use the links below to access the remainder of the tutorial.
- iPhone App Development Tutorial – Part 1
- iPhone App Development Tutorial – Part 2
- iPhone App Development Tutorial – Part 3
- iPhone App Development Tutorial – Part 4