我试图将UILabel与在类中创建的IBOutlet链接起来。
我的应用程序崩溃与以下错误。
这是什么意思?
我该怎么解决呢?
***终止应用由于未捕获异常'NSUnknownKeyException',原因:'[<UIViewController 0x6e36ae0> setValue:forUndefinedKey:]:这个类不是键值编码兼容的键XXX。'
我试图将UILabel与在类中创建的IBOutlet链接起来。
我的应用程序崩溃与以下错误。
这是什么意思?
我该怎么解决呢?
***终止应用由于未捕获异常'NSUnknownKeyException',原因:'[<UIViewController 0x6e36ae0> setValue:forUndefinedKey:]:这个类不是键值编码兼容的键XXX。'
当前回答
这个错误是另一回事!
这是我如何解决它。我使用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.
欢呼,
其他回答
在我的情况下,这是一个错误在故事板源代码,遵循以下步骤:
首先以源代码的形式打开故事板 搜索<connections> 删除不需要的连接
例如:
<connections>
<outlet property="mapPostsView" destination="4EV-NK-Bhn" id="ubM-Z6-mwl"/>
<outlet property="mapView" destination="kx6-TV-oQg" id="4wY-jv-Ih6"/>
<outlet property="sidebarButton" destination="6UH-BZ-60q" id="8Yz-5G-HpY"/>
</connections>
如你所见,这些是你的代码变量名和storyboard布局xml标签之间的连接;)
如果您试图观察一个不存在的值,请注意。
这发生在我身上只是因为我正在观察一个文本字段的“文本”属性,而我应该观察的是“文本”属性。
我通过两件事解决了这个问题:
视图的固定类引用:
重新进口所有Outlets:
选择器对象是否未连接?
哈哈,54个答案,没有一个是我的解决方案。谈论一个常见的错误。
在我的情况下,这是因为我在我的VC上有一个选择器对象,并没有为它设置一个出口和动作。
当我只是想看看布局如何时,我经常不连接按钮等。但对于采摘者来说,你似乎做不到这一点。
我也有同样的问题。我重置了模拟器。删除和添加按钮控件。终于搞干净了。:)由于堆栈溢出。不知怎么的,我的代码变得很好,开始工作。