Swift setValue:forUndefinedKey:]:此类与键的编码不兼容 [英] Swift setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key

查看:667
本文介绍了Swift setValue:forUndefinedKey:]:此类与键的编码不兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Xcode项目 Alamofire POD 中手动删除了,自此以来,我在任何 UIViewControllers 中出错> UIButton IBOutlet 添加了。

I removed manually from my Xcode project Alamofire POD and since this time, I have errors in some UIViewControllers on any UIButton IBOutlet added.

我遇到以下错误:


由于未捕获的异常'NSUnknownKeyException'而终止应用程序,原因:'[
setValue:forUndefinedKey:]:此类不是键值
符合键btListOrdo的编码

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key btListOrdo

我试图创建一个新的 UIViewController 并将其链接到我的 StoryBoard ,但是我遇到了相同的错误...。

I tried to create a new UIViewController and link it to my StoryBoard but I have the same error....

我要添加以下 IBOutlet

@IBOutlet weak var btListOrdo: UIButton!

请注意,这些链接在删除POD之前正常工作,我可能已经删除了一些强制性内容,但我找不到它。

Notice that those links worked properly before the POD removal, I may have removed something mandatory but I'm not able to find it.

这是我的按钮的参考插座的屏幕截图:

here is the screenshot of the referencing outlets of my button:

我也尝试清理项目,清理了Build Folder,删除了Derived Data,重置了模拟器的内容和设置,但是相同的结果...

I also tried to clean the project, cleaned the Build Folder, deleted Derived Data, Reset Content and Settings of the simulator but same result...

推荐答案

好吧,我刚刚遇到了同样的问题,这是因为有多个目标。我无法弄清楚为什么它在某些情况下可以完美运行,而在其他情况下却不能。问题实际上与视图控制器上的模块定义有关,我想这可能可以解释为什么当您完全重新创建控制器时,该问题似乎已经神奇地解决了。在我的矿井上,我将模块设置为我的目标之一,所以当我运行第二个目标时,它并没有关联。如果您有多个目标,请确保清空VC上崩溃的模块框(在情节提要上),然后勾选从目标继承模块。

Okay I just faced the same issue and it was due to having multiple targets. I couldn't figure out why it would run perfectly fine in some instances, yet not others. The issue is actually with the Module definition on the view controller, I'm guessing that this may explain why when you completely recreate the controller the issue seems magically fixed. On mine I had the Module set to one of my targets, so when I ran a second target it wasn't associated. If you have multiple targets make sure you empty the Module box on the VC that crashes (on your storyboard) and tick Inherit Module From Target.

希望这会有所帮助

这篇关于Swift setValue:forUndefinedKey:]:此类与键的编码不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆