Hito_kun
Hito_kun

Reputation: 992

Outlet doesn't show up in Interface Builder (Xcode 3) nor Xcode4

I'm learning to develop iOS apps (I am a total newbie in Objective-C and Cocoa), and I am doing this really simple example exercise (two buttons that shows Left or Right button is pressed in a Label).

I just create an IBOutlet and a couple of code lines, save both AppViewController files and when trying to connect the IBOutlet with the actual label in the Interface Builder, the outlet doesn't show up.

I'm using the iOS SDK 4.3

Here's the source code:

//
//  BotonViewController.h
//  Boton
//
//  Created by Abu on 5/23/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface Hola_MundoViewController : UIViewController {

IBOutlet UILabel *statusText; 

}

@property (retain, nonatomic) UILabel *statusText;

-(IBAction)buttonPressed: (id)sender;

@end

And

//
//  BotonViewController.m
//  Boton
//
//  Created by Abu on 5/23/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "BotonViewController.h"

@implementation Hola_MundoViewController
@synthesize statusText;

-(IBAction)buttonPressed: (id)sender
{
NSString *title = [sender titleForState:UIControlStateNormal];
NSString *newText = [[NSString alloc] initWithFormat:
                     @"%@ button pressed.", title];
statusText.text = newText;
[newText release];
}

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:         (UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}


- (void)dealloc {
[statusText release];
    [super dealloc];
}

@end

Well, that's it, hope you can help me with this, probably is a silly mistake, but I've browsed a lot and I cannot find a solution.

Upvotes: 0

Views: 2290

Answers (1)

arclight
arclight

Reputation: 5310

Your property declaration should look like this

@property (retain, nonatomic) IBOutlet UILabel *statusText;

Upvotes: 2

Related Questions