Finally, I got the application working with interactions. I credit http://zone12.co.uk/iCode/tut1.html for this information.
Step 1: Create a new Cocoa Touch Application.

Step 2: Pick the directory and name for your application.
Step 3: As per the current template, it doesn’t generate Interface Builder file for you. Create a new one after opening the Interface builder in parallel as shown below: (Choose Cocoa Touch - View)
Step 4: Design the screen as shown below. Use Placeholder text for your input box with the text shown in gray color.
Step 5: You have to save the file to associate with the project. (Save it in the same folder as the other files).
Step 6: It will prompt you to add this to the created project for deployment. Click the checkbox and click “Add”.
Step 7: Now Choose “File’s Owner” object and select “Object Identity” tab of the Inspector (Tools - Inspector).
Step 8: Now change the Class (which is NSObject) to ButtonClickAppDelegate.
Step 9: Create Outlets for Text Box & Label. Also create Actions for button as shown below after clicking this Object. Select UILabel and UITextField as the type for those new outlets.
Step 10: Connect this object to the outlets created. Choose connections tab on the Inspector. Drag each one and connect them as shown below:
Do the same for text box and select textBoxOutlet.
Step 11: Click on the Button. Select Button Connections inspector. Drag “Touch Up Inside” event to the object and Choose “buttonClicked”
Step 12: Click object. Choose File - Write Files… menu item. Overwrite the same Appdelegate file. Choose merge and finish the changes. They should look like the following:
Step 13: Save & Close the Interface Builder.
Step 14: Fix .m file with the following code for the new event handler.
- (IBAction)buttonPressed:(id)sender {
[labelOutlet setText:textBoxOutlet.text];
}
self.contentView = [[[NSBundle mainBundle] loadNibNamed:@”MainWindow” owner:self options:nil] objectAtIndex:0];
Step 16: Save - Click Build & Go
Download the project: buttonclick











April 2nd, 2008 at 9:51 pm
[...] blue collar scientist wrote an interesting post today onHere’s a quick excerptFinally, I got the application working with interactions. I credit http://zone12.co.uk/iCode/tut1.html for this information. Step 1: Create a new Cocoa Touch Application. Step 2: Pick the directory and name for your application. … [...]
April 2nd, 2008 at 11:21 pm
[...] iPhone Native Application - Button Click Tutorial By muthu Finally, I got the application working with interactions. I credit http://zone12.co.uk/iCode/tut1.html for this information. Step 1: Create a new Cocoa Touch Application. Step 2: Pick the directory and name for your application. … muthu arumugam blog - http://techblog.muthuka.com/ [...]
April 8th, 2008 at 12:45 pm
You should be able to remove MyView.m and MyView.h from the classes and remove all references in the Controller object to make this tutorial clean. When you use the template which XCode provides, it automatically creates those views to hand code it.
July 24th, 2008 at 9:43 am
Hi,
Thanks for putting this simple example online. I’ve been working quite well through through the “Cocoa Programming for Mac OS” and the today I decided to start writing something simple on for the iPhone simulator and it all went wrong with a “unrecognized selector sent to instance” error after setting the target of a button. After reading through your example I realised that I was binding the action to the wrong controller, should have tied it to the File Owner.
Many thanks,
Lee