Interface builder problem: When hooking up an IBOutlet, getting "this class is not key value coding-

Posted by Robert on Stack Overflow See other posts from Stack Overflow or by Robert
Published on 2010-05-05T11:36:31Z Indexed on 2010/05/05 11:38 UTC
Read the original article Hit count: 363

Here is what I do:

1) Create New UIViewController subclass , tick with NIB for interface builder

2) In the header:

@interface QuizMainViewController : UIViewController 
{
    UILabel* aLabel;
} 

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

@end

3) In the .m

#import "QuizMainViewController.h"    

@implementation QuizMainViewController

@synthesize aLabel;

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

@end

4) Open the NIB In interface builder, drag a new UILabel into the view.

I test the program here and it runs fine.

5) right click on file's owner, connect 'aLabel' from the Outlets to the UILabel.

I run here and it crashes. Message from log:

* Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key aLabel.'

© Stack Overflow or respective owner

Related posts about iphone

Related posts about interface-builder