此类与键setOutput的键值编码不兼容

编程入门 行业动态 更新时间:2024-10-05 05:18:06
本文介绍了此类与键setOutput的键值编码不兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是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的键值编码不兼容

本文发布于:2023-11-26 18:59:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634794.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:此类   键值   不兼容   setOutput

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!