我试图将UILabel与在类中创建的IBOutlet链接起来。

我的应用程序崩溃与以下错误。

这是什么意思?

我该怎么解决呢?

***终止应用由于未捕获异常'NSUnknownKeyException',原因:'[<UIViewController 0x6e36ae0> setValue:forUndefinedKey:]:这个类不是键值编码兼容的键XXX。'


当前回答

当我试图实现一个表的自定义ViewCell时,我有这个错误。当我突出显示XIB的视图控制器并连接到CellView中的元素时,会导致错误“这个类不是键值编码兼容的键”,一旦我删除了这些,它就摆脱了错误。

删除下图中的连接。

只要确保你只有与表格视图单元格的连接。要检查,单击表视图单元格,并在检查器中寻找您的连接。

其他回答

如果您试图观察一个不存在的值,请注意。

这发生在我身上只是因为我正在观察一个文本字段的“文本”属性,而我应该观察的是“文本”属性。

这个错误是另一回事!

这是我如何解决它。我使用xcode版本6.1.1和使用swift。每次我的应用程序尝试执行segue跳转到下一个屏幕时,我都得到这个错误。这是我所做的。

Checked that the button was connected to the right action.(This wasn't the problem, but still good to check) Check that the button does not have any additional actions or outlets that you may have created by mistake. (This wasn't the problem, but still good to check) Check the logs and make sure that all the buttons in the NEXT SCREEN have the correct actions, and if there are any segues, make sure that they have a unique identifier. (This was the problem) One of the segues did not have a unique identifier One of the buttons had an action and two outlets that I created by mistake. Delete any additional outlets and make sure that you the segues to the next screen have unique identifiers.

欢呼,

您只需要指定IBOutlet一次,IBOutlet标签您的ivar是不必要的。 你在用你的UIViewController实例化你的NIB吗?在某些时候,你应该调用[SecondView initWithNibName:@"yourNibName" bundle:nil];

同样的问题。我的解决方案是在Main storyboard下拉菜单中放置正确的storyboard值。我重新命名了mainstoryboard。故事板,但不重置部署信息。

对于我来说,我必须单击文件的Owner对象并导航到连接并删除有问题的连接