对于键setOutput ,此类不符合键值编码

我是iOS / Objective-C的新手,我正在努力学习。 我正在跟随Sam的自学iOS。 我正在做一个名为Hello Noun的项目,它不需要显示Hello World,而是接受输入并显示“Hello Input”。

在项目上工作,一切都很好,没有错误。 但当我去Build然后运行应用程序时,它崩溃了说;

'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key setOutput.' 

并指向强调这些行的main.m文件;

 #import  #import "AppDelegate.h" int main(int argc, char * argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } 

使用的其余代码如下;

ViewController.m

  @interface ViewController () @property (weak, nonatomic) IBOutlet UILabel *userOutput; @property (weak, nonatomic) IBOutlet UITextField *userInput; - (IBAction)setOutput:(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)setOutput:(id)sender { self.userOutput.text=self.userInput.text; } @end 

我是新手,我只是得到了方向,所以我不太清楚发生了什么。 任何帮助都将无法理解。

转到你的ViewController xib / Storyboard右键单击File's Owner你应该找到一个黄色警报图标删除那个连接,它应该解决你的问题。