It’s easy to add a property to a UIViewController, but how do you access it from Interface Builder when you’re done?

Let’s say you have a UILabel and a UITextView. To connect them to objects in IB, you need to add an IBOutlet attribute to each of their @property declarations:

//  CustomViewController.h
//  App Name
//  Created by Miscellanea on 11/10/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.

#import <UIKit/UIKit.h>

@interface CustomViewController : UIViewController
    UILabel *myLabel;
    UITextView *myTextView;

@property (nonatomic, retain) IBOutlet UILabel *myLabel;
@property (nonatomic, retain) IBOutlet UITextView *myTextView;


Now you can switch to Interface Builder and create the same objects in the corresponding user interface (.xib) file.

To connect them, select each object in IB and open the Connections Inspector. (Command-Option-6 or View > Utilities > Connections Inspector) Under Referencing Outlets, click on the circle to the right of “New Referencing Outlet” and drag it to the File’s Owner. It should draw a blue line as you do this. Then select the appropriate property for each object in the menu that appears.

Afterwards you should see a new connection in Referencing Outlets. That’s it! Now you can configure the objects in your view controller’s implementation file.