I am really new to iOS programming. I am just trying to make a button click event and when I run simulator an exception comes up
2014-10-27 12:00:00.859 practiceapp[682:28288] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x7f95fb721120> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key button1.'
ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *label;
@property (weak, nonatomic) IBOutlet UITextField *textfield;
@property (weak, nonatomic) IBOutlet UIButton *button;
@end
ViewController.m
#import "ViewController.h"
@interface ViewController ()
@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)changebuttonaction:(id)sender {
NSString *st = self.textfield.text;
self.label.text=st;
[self.textfield resignFirstResponder];
}
@end
You can find the source here: https://github.com/liaoxsong/practiceapp
You have three different views which has invalid connection. If you go and look at the connection inspector for your viewcontrollers, you will see that button1, label1 and textField1 are invalid. Those are listed as !.
See the firgure closely here.
If you remove button1, label1 and textField1 connection from connection inspector by clicking X button, you should be good to go.