我是iOS/Objective-C的新手,正在尝试学习.我正在Sam的自学iOS中关注.我正在执行一个名为Hello Noun的项目,该项目不显示Hello World,而是接收输入并显示"Hello Input".
I am brand new to iOS/Objective-C and I am trying to learn. I am following along in Sam's Teach yourself iOS. I am doing a project called Hello Noun, where instead of displaying Hello World, it takes an input and displays "Hello Input".
在项目上工作,一切都很好,没有错误.但是当我去Build然后运行该应用程序时,它崩溃了;
Working on the project, everything was fine, and there were no errors. But when I went to Build and then Run the app, it crashed saying;
'NSUnknownKeyException', reason: '[<ViewController 0xa064620> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key setOutput.'并指向突出显示这些行的main.m文件;
and pointed to main.m file highlighting these lines;
#import <UIKit/UIKit.h> #import "AppDelegate.h" int main(int argc, char * argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } }其余的代码在下面;
ViewController.m
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我对此很陌生,我只是想了解我的情况,所以我不太确定发生了什么.任何帮助将不胜感激.
I am new to this, and I'm just getting my bearings so I'm not quite sure what is happening. Any help would be beyond appreciated.
推荐答案转到您的ViewController xib/Storyboard,右键单击File's Owner,您会发现一个黄色的警报图标,那里的连接已删除,它应该可以解决您的问题
Go to your ViewController xib/Storyboard right click on the File's Owner you should find a yellow alert icon there delete that connection , it should solve your problem.
更多推荐
此类与键setOutput的键值编码不兼容
发布评论