gpt4 book ai didi

ios - Xcode - 如何修复 'NSUnknownKeyException' ,原因 : … this class is not key value coding-compliant for the key X"error?

转载 作者:行者123 更新时间:2023-11-30 11:04:53 25 4
gpt4 key购买 nike

我正在尝试将 UILabel 与在我的类中创建的 IBOutlet 链接。

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

这是什么意思?

如何修复它?

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x6e36ae0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key XXX.'

最佳答案

您的 xib 中的连接可能较差。

我多次遇到此错误。虽然在这种情况下 TechZen 的答案是绝对正确的,但另一个常见原因是当您更改 .h/.m 中 IBOutlet 属性的名称时,您已经将其连接到 Nib 中的文件所有者.

从你的 Nib :

  1. 在 IB 中选择对象并转到“连接检查器”。
  2. 在“引用 socket ”下,确保您的对象尚未连接到旧属性名称...如果是,点击小“x”删除引用并再次构建。

    enter image description here

如果您使用 Storyboard,另一个常见原因是您的 UIButton 可能有多个分配(解决方案与 Nib 几乎相同):

  1. 打开 Storyboard并右键单击 UIButton
  2. 您将看到该按钮有多个分配/引用。删除带有小“x”的“Main...”灰色窗口之一:

    example 2

关于ios - Xcode - 如何修复 'NSUnknownKeyException' ,原因 : … this class is not key value coding-compliant for the key X"error?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52826949/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com