pdenlinger
pdenlinger

Reputation: 3917

IBOutlets Won't Appear in Interface Builder

Have two IBOutlets which won't appear in File's Owner to connect to even though they are included in the view controller files. Why?

Here is the code for the interface and implementation files. Using Xcode 4.2.

CoinTossViewController.h

#import <UIKit/UIKit.h>

@interface CoinTossViewController : UIViewController {
    UILabel *status;
    UILabel *result;
}

@property (nonatomic, retain)UILabel *status;
@property (nonatomic, retain)UILabel *result;

- (IBAction)callHeads;
- (IBAction)callTails;


@end

ToinCossViewController.m

#import "CoinTossViewController.h"
#import <QuartzCore/QuartzCore.h>

@implementation CoinTossViewController

@synthesize status, result;

- (void)simulateCoinToss:(BOOL)userCalledHeads {
    BOOL coinLandedOnHeads = (arc4random() % 2) == 0;

    result.text = coinLandedOnHeads ? @"Heads" : @"Tails";

    if (coinLandedOnHeads == userCalledHeads)
        status.text = @"Correct!";

    else 
        status.text = @"Wrong!";

    CABasicAnimation *rotation = [CABasicAnimation
                              animationWithKeyPath:@"transform.rotation"];
    rotation.timingFunction = [CAMediaTimingFunction     functionWithName:kCAMediaTimingFunctionEaseOut];
    rotation.fromValue = [NSNumber numberWithFloat:0.0f];
    rotation.toValue = [NSNumber numberWithFloat:720 * M_PI / 180.0f];
    rotation.duration = 2.0f;
    [status.layer addAnimation:rotation forKey:@"rotate"];

    CABasicAnimation *fade = [CABasicAnimation animationWithKeyPath:@"opacity"];
    fade.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
    fade.fromValue = [NSNumber numberWithFloat:0.0f];
    fade.toValue = [NSNumber numberWithFloat:1.0f];
    fade.duration = 3.5f;
    [status.layer addAnimation:fade forKey:@"fade"];
}

 - (IBAction)callHeads
{
     [self simulateCoinToss:YES];
}

- (IBAction)callTails
{
    [self simulateCoinToss:NO];
}

- (void) viewDidUnload
{
    self.status = nil;
    self.result = nil;
}

- (void) dealloc 
{ 
    [status release];
    [result release];
    [super dealloc];
}
@end

Upvotes: 0

Views: 190

Answers (2)

MCannon
MCannon

Reputation: 4041

try changing the header to:

#import <UIKit/UIKit.h>

@interface CoinTossViewController : UIViewController {
    UILabel *status;
    UILabel *result;
}

@property (nonatomic, retain)IBOutlet UILabel *status;
@property (nonatomic, retain)IBOutlet UILabel *result;

- (IBAction)callHeads;
- (IBAction)callTails;


@end

Upvotes: 1

rob mayoff
rob mayoff

Reputation: 385998

You don't have any IBOutlets defined there. Did you want status and result to be outlets? If so, do this:

@property (nonatomic, retain) IBOutlet UILabel *status;
@property (nonatomic, retain) IBOutlet UILabel *result;

Upvotes: 5

Related Questions