
Because of the recent announcement of the iPad 2 more people are going to want to learn how to develop for the iPhone OS. I recently purchased an iPad 2 3G with o2, so far the broadband has been flawless.
This tutorial will be a basic walk-through for beginners who want to start developing.
The application that we will be creating will consist of two button and one label.
Create a new project
First of all open Xcode and click "Create a new Xcode project". Select View-based Application and then iPad as the product.

Save the project as Tutorial.
Outlets and Actions
For things such as labels and textfields we use IBOutlets and for buttons we use IBActions. IB stands for Interface Builder and is what we will use to create our interface and link the connections.
To add our outlets and actions open up TutorialViewController.h.
Under @interface TutorialViewController : UIViewController { add:
IBOutlet UILabel *currentNumber;
Then before @end add:
-(IBAction)incrementNumber:(id)sender; -(IBAction)decrementNumber:(id)sender;
Save TutorialViewController.h.
Create the interface and make connections
Open up TutorialViewController.xib. From the library drag one labels and two buttons.

Control + click the File's Owner object and drag it to the label then select currentNumber; now go from the minus and plus button to the File's Owner object and select decrementNumber for the minus button and incrementNumber for the plus button.

Save TutorialViewController.xib and close Interface Builder.
The Code
Open TutorialViewController.m. Below the implementation we need to create an integer called number and set the value to 0.
int number = 0;
We now need to create methods for when the increment and decrement buttons are pressed.
When the increment button is pressed we will increment the number integer by 1 then set the value of currentNumber to number by using a formatted string.
-(IBAction)incrementNumber:(id)sender { number++; [currentNumber setText:[NSString stringWithFormat:@"%d", number]]; }
and for decrement its the same but we decrement the number integer by 1.
-(IBAction)decrementNumber:(id)sender { number-; [currentNumber setText:[NSString stringWithFormat:@"%d", number]]; }
Build and Run
Press the Build and Run button (command + return) and your app will compile then open.

Download
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.

Typo: when you decrement currentNumber in the last step the expression should be:
number--;
NOT
number-;
Brilliant work. I consistently come across truly exceptional discussions here on your blog page.
Should be -- indeed, instead of -. Also, I discovered that on the first load, the label just says label, and it is upon the change of the value that the label is updated to that specific value. This can simply be fixed by adding one line to the (commented) viewDidLoad function, the complete function should be:
- (void)viewDidLoad {
[currentNumber setText:[NSString stringWithFormat:@"%d", number]];
[super viewDidLoad];
}
Agaain, it is there on default, but it is commented by a /* comment before and after it. Just add the currentnumer line, and the label will be updated upon start. Great small but simple tutorial, learned 10x more from this than browsing the apple ios documentation for a whole day... A great start for beginners! Thanks!