我试图将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.
欢呼,
其他回答
我犯了个愚蠢的错误。所以我决定在这里分享,希望这能帮助到其他像我一样的人。
我在我的项目中有另一个子模块,我在主模块中命名了一个与另一个类同名的新类,我的新类没有xib文件(100%由代码),但主模块中的另一个类有xib文件。我认为Xcode在主模块中的xib文件错误地链接了新类。
坠机的原因与消息:
这个类对于键tableView来说不符合键值编码。
我从头文件中删除了该属性。我找不到它的任何引用,但调试错误仍然引用它。我发现nib文件仍然有对它的引用。我删除了引用它的块,一切都修复了。
在Project Navigator中,
找到Nib (xib)文件。右键单击并查看源。我删除了下面的完整部分
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">DeleteLabel</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="774585933"/>
</object>
<int key="connectionID">20</int>
</object>
同样的问题。我的解决方案是在Main storyboard下拉菜单中放置正确的storyboard值。我重新命名了mainstoryboard。故事板,但不重置部署信息。
当我的视图控制器最初有一个.xib文件时,这种情况发生在我身上,但现在是以编程方式创建的。
尽管我已经从这个项目中删除了.xib文件。用户的iPhone/iPad可能包含这个视图控制器的.xib文件。
尝试加载.xib文件通常会导致以下崩溃:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x18afe0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key welcomeLabel.'
以编程方式创建时的解决方案可能是这样的:
-(void)loadView {
// Ensure that we don't load an .xib file for this viewcontroller
self.view = [UIView new];
}
在我的情况下,这是一个错误在故事板源代码,遵循以下步骤:
首先以源代码的形式打开故事板 搜索<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标签之间的连接;)