我试图将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.

欢呼,

其他回答

线程1:“[setValue:forUndefinedKey:]:这个类不符合键xxx的键值编码。”

你可以在以下情况下得到这个错误:

xib + UITableViewHeaderFooterView

当你使用UITableView显示头/脚它扩展了UITableViewHeaderFooterView并连接到。swift文件和

设置文件的属主

正确的方法:

为containerView设置自定义类

我犯了同样的错误,只是形式略有不同:

在接口构建器中,我有一个自定义子控制器的导航控制器。这个类的名称设置正确,但是NIB名称(选择子控制器,转到属性检查器)被设置为错误的文件(基本上是一个不同的目标)。将其重置为正确的文件名解决了这个问题。

如果它只是一个iPhone应用,而不是一个通用的应用,请确保以下字段为空:

目标>摘要> iPhone/iPod部署信息>主界面

如果你在这里指定了xib,它会崩溃。

导致这种情况的另一个原因是,您声明该属性实现为@dynamic,但类无法在父类中找到它。

我不得不从模拟器/iPhone中删除应用程序来消除这个错误。