I face some problem in creating new application using xib and objective-C. I am using xib instead of storyboard. Every time I created new project, added some label and button, then It worked well. It showed all object that I attached.
Problem starts when I declare them on my viewController class, and connect them with the object
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7aa91da0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key firstLabel.'
And this is my File's Owner connection view of my .xib
Here is my ViewController.m that contain outlet and action I declared
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *firstLabel;
- (IBAction)firstButton:(id)sender;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)firstButton:(id)sender {
NSLog(@"worked!");
}
@end
I am forced to use .xib in Xcode 7 that apple already left behind instead of the powerful storyboard. Any help would be appreciated. Thank you!
ViewController
to use? – tuledev