Adding Objects To A View

Declare The Inputs And Output in #ViewController.h

Declare the objects you will output to (control from code) and methods for the objects providing input. Examples:


	IBOutlet UILabel *SomeLabel1;
	IBOutlet UILabel *SomeLabel2;
	IBOutlet UITextField *SomeTextField1;
	//### Remember to release any view objects you add in viewDidUnload and dealloc ###
}
- (IBAction)MyButtonInputMethod1:(id)sender;
- (IBAction)MyButtonInputMethod2:(id)sender;
If your View could get unloaded you must release objects you’ve created (or you’ll have a memory leak) in #ViewController.m

//*************************************
//*************************************
//********** VIEW DID UNLOAD **********
//*************************************
//*************************************
- (void)viewDidUnload
{
	[super viewDidUnload];

	[SomeLabel1 release];
	SomeLabel1 = nil;

	[SomeLabel2 release];
	SomeLabel2 = nil;

	[SomeTextField1 release];
	SomeTextField1 = nil;

//*****************************
//*****************************
//********** DEALLOC **********
//*****************************
//*****************************
- (void)dealloc
{
	[SomeLabel1 release];
	[SomeLabel2 release];
	[SomeTextField1 release];

	[super dealloc];
}
Open the XIB file to open the Interface builder and drag on the library objects

Open the ‘View’

Drag objects from the library onto the view and lay out as required. Set properties as required (use the size attributes if you need to anchor objects for applications that will resize for different orientations)
Sill in the Interface builder right click Files Owner (or #AppDelegate for a simple app) to show the connection panel.

Outlets (Labels etc)

Drag the circle beside each Outlet (each of the objects you defined in #ViewController.h – e.g. IBOutlet UILabel *SomeLabel1;) onto the view object it is to connect to. You are dragging from the object with the pointer to the object you are pointing to. (If you don’t see the Outlets you expect make sure you saved the .h file – it doesn’t update until saved).

Event Objects (Buttons etc)

For objects that will generate events the code needs to receive select the object and then right click. Drag the delegate to Files Owner (or #AppDelegate) in the main window (you are dragging from the object that is delegating to the object that will be the delegate).

Buttons – Default Send Event = TouchUpInside

Create the methods to respond to events in #ViewController.h

- (IBAction)MyButtonInputMethod1:(id)sender
{
}