Xcode 3.2.1, Interface Builder and Outlets

First day of iPhone development and I've already hit a problem.  Using the Stanford iPhone Application Development course as a crash course the first lecture had a demo application  using a program called "Interface Builder" to hook together a bunch of pieces for a basic UI.  Well the most important part, hooking the pieces together, changed with version 3.2.  Rather than creating the outlets from the interface they must be added explicitly to the header file.

For completeness, here is the code which needs to be added (it was difficult to read from the video)

MyConenctor.h
@interface MyController : NSObject {
IBOutlet UILabel *label;
IBOutlet UISlider *slider;
}

-(IBAction)changeLabelText:(id)sender;


MyConnector.m
-(IBAction)changeLabelText:(id)sender{
int value = slider.value;
label.text = [NSString stringWithFormat: @"%d", value];
}

3 comments:

Isaac Johnson said...

thanks. kept trying to pinch and zoom on my phones screen with no luck

Isaac Johnson said...

Also, I created those outlets from the interface builder, its just in a different window. His demo showed it in the inspector. In the latest IB, it's in the Library window (selected classes from the Objects|Classes|Media selector, pick your controller, bottom half).

Will Winder said...

Thanks for the tip, I looked all over the place trying to find how to create an outlet in IB.

Post a Comment