xcode 由于未捕获的异常“NSUnknownKeyException”而终止应用程序,原因:“[<UIApplication 0x9e37580> setValue:forUndefinedKey:]:
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15256744/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x9e37580> setValue:forUndefinedKey:]:
提问by Simon Andersson
I am making an App in Xcode and i have been getting the error
我正在 Xcode 中制作应用程序,但出现错误
"Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key achiev"
“由于未捕获的异常‘NSUnknownKeyException’而终止应用程序,原因:‘[setValue:forUndefinedKey:]:此类不符合关键实现的关键值编码”
recently. I have been searching for hours and i cannot seem to find an answer that matches my case. This error happened when i added new objects and removed some objects in the .h file but i have double-triple-quadruple checked that every single outlet is connected rightly. Nothing is phantom connected or not connected, everything is all good. When i tried to remove the key mentioned in the error code, it went to the next key and it kept on, basically every single connection is bad. I have connected the view properly (i think) since when i add new outlets in the .h file i am able to see it in the xib file and connect it, but every time i open the app i still get this error.
最近。我已经搜索了几个小时,但似乎找不到与我的情况相符的答案。当我添加新对象并删除 .h 文件中的一些对象时,会发生此错误,但我进行了双三重四重检查以确保每个插座都正确连接。没有幻相连接或不连接,一切都很好。当我试图删除错误代码中提到的密钥时,它转到下一个密钥并保持不变,基本上每个连接都坏了。我已经正确连接了视图(我认为),因为当我在 .h 文件中添加新的插座时,我能够在 xib 文件中看到它并连接它,但是每次我打开应用程序时我仍然会收到这个错误。
i recently changed the view controller id thingy to XcodeProjectViewController and i have checked all my files (h, m and xib) to see that they are matching.
我最近将视图控制器 ID thingy 更改为 XcodeProjectViewController 并且我检查了我的所有文件(h、m 和 xib)以查看它们是否匹配。
回答by GeneCode
I encountered this error message in my latest app, Label Dispenser PRO. It is pretty annoying because all codes seemsok (because they are).
我在我的最新应用 Label Dispenser PRO 中遇到了此错误消息。这很烦人,因为所有代码似乎都可以(因为它们是)。
After a few hours of investigating, it turns out (for my case) the problem was I specified (accidentally?) XIB files as Main Interface for the "iPad development info" section in Target's Summary area. Here's the pic to illustrate this location:
经过几个小时的调查,结果(就我而言)问题是我指定(意外?)XIB 文件作为 Target 摘要区域中“iPad 开发信息”部分的主界面。这是说明此位置的图片:
Deleting this field solved the problem. I guess this happens because compiler is confused since I was manually presenting the XIB based on if statement evaluating "if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)" in the AppDelegate.
删除该字段解决了问题。我猜这是因为编译器很困惑,因为我是根据在 AppDelegate 中评估“if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)”的 if 语句手动呈现 XIB 的。
Hope this helps someone. Cheers.
希望这可以帮助某人。干杯。