csdnceshi62 2010-06-21 19:57 采纳率: 100%
浏览 973
已采纳

这意味着什么? "'NSUnknownKeyException',原因: ... 此类不与键 x 兼容

I'm trying to link a UILabel with an IBOutlet created in my class.

My application is crashing with the following error. What does this mean? How can I fix it?

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

转载于:https://stackoverflow.com/questions/3088059/what-does-this-mean-nsunknownkeyexception-reason-this-class-is-not-key-v

  • 写回答

29条回答 默认 最新

  • from.. 2014-03-06 19:57
    关注

    Your view controller may have the wrong class in your xib.

    I downloaded your project.

    The error you are getting is

    'NSUnknownKeyException', reason: '[<UIViewController 0x3927310> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key string.'

    It is caused by the Second view controller in MainWindow.xib having a class of UIViewController instead of SecondView. Changing to the correct class resolves the problem.

    By the way, it is bad practice to have names like "string" in Objective-C. It invites a runtime naming collision. Avoid them even in once off practice apps. Naming collisions can be very hard to track down and you don't want to waste the time.

    Another possible reason for this error: when copying & pasting elements from one controller into another, Xcode somehow keeps that link to the original controller, even after editing & relinking this element into the new controller.

    Another possible reason for this error:

    Bad Outlet.

    You have either removed or renamed an outlet name in your .h file.

    Remove it in .xib or .storyboard file's Connection Inspector.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(28条)

报告相同问题?

悬赏问题

  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛