我试图将UILabel与在类中创建的IBOutlet链接起来。
我的应用程序崩溃与以下错误。
这是什么意思?
我该怎么解决呢?
***终止应用由于未捕获异常'NSUnknownKeyException',原因:'[<UIViewController 0x6e36ae0> setValue:forUndefinedKey:]:这个类不是键值编码兼容的键XXX。'
我试图将UILabel与在类中创建的IBOutlet链接起来。
我的应用程序崩溃与以下错误。
这是什么意思?
我该怎么解决呢?
***终止应用由于未捕获异常'NSUnknownKeyException',原因:'[<UIViewController 0x6e36ae0> setValue:forUndefinedKey:]:这个类不是键值编码兼容的键XXX。'
当前回答
我也有这个问题。我将带有IBOutlet的视图从一个xib文件复制到另一个xib文件。即使我已经删除了旧的引用并创建了一个新的引用,这个错误仍然发生。
我最终重新启动xcode来解决这个问题。
其他回答
在我的例子中,是模块被指定到错误的目标。简单地删除模块名并从目标中检查Inherit module就可以了。
我在一个有两个目标(有自己的MainWindow XIB)的项目中遇到了类似的问题。对我来说,导致这个错误的根本问题是UIViewController类没有包含在第二个项目的资源列表中。例如,界面构建器允许我在主窗口中指定它。Xib,但在运行时系统无法定位类。
例如,cmd-点击有问题的UIViewController类,并仔细检查它是否包含在“Targets”选项卡中。
这个错误是另一回事!
这是我如何解决它。我使用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.
欢呼,
有时swift文件没有从目标中添加或删除,请转到目标——>构建设置——>编译源——>查看是否缺少任何所需的swift类文件。 在我的情况下,应用程序崩溃,由于swift源文件不存在编译。
我也有同样的症状。根本原因是源文件的“目标成员资格”没有设置为正确的目标。我假设这意味着我的类不会被构建并包含在我的应用程序中。
纠正它:
突出显示你的.m文件。 在右窗格中,选择文件检查器。 在“Target Membership”部分下,确保选中了适当的构建目标。
希望这能帮助到一些人。