iOS5 和 XCode4 错误 - 由于未捕获的异常“NSUnknownKeyException”而终止应用程序

Posted

技术标签:

【中文标题】iOS5 和 XCode4 错误 - 由于未捕获的异常“NSUnknownKeyException”而终止应用程序【英文标题】:iOS5 and XCode4 Error - Terminating app due to uncaught exception 'NSUnknownKeyException' 【发布时间】:2011-11-13 14:38:01 【问题描述】:

我最近更新了 Xcode 以使用 ios5 SDK。由于更新我的应用程序在启动屏幕上崩溃。以前该应用程序可在 4.3 和 iPhone(iOS5 之前)上运行。 错误指向:int retVal = UIApplicationMain(argc, argv, nil, nil); 在main.m中

控制台返回以下内容:

GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug  8 20:32:45 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".Attaching to process 3903.
2011-11-13 22:11:05.421 BlastCalc[3903:10d03] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x5c1b600> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key averageChargeLengthLabel.'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x00e7b5a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x00fcf313 objc_exception_throw + 44
    2   CoreFoundation                      0x00e7b4e1 -[NSException raise] + 17
    3   Foundation                          0x0084d677 _NSSetUsingKeyValueSetter + 135
    4   Foundation                          0x0084d5e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
    5   UIKit                               0x002c930c -[UIRuntimeOutletConnection connect] + 112
    6   CoreFoundation                      0x00df18cf -[NSArray makeObjectsPerformSelector:] + 239
    7   UIKit                               0x002c7d23 -[UINib instantiateWithOwner:options:] + 1041
    8   UIKit                               0x002c9ab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
    9   UIKit                               0x000cf17a -[UIApplication _loadMainNibFile] + 172
    10  UIKit                               0x000cfcf4 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 291
    11  UIKit                               0x000da617 -[UIApplication handleEvent:withNewEvent:] + 1533
    12  UIKit                               0x000d2abf -[UIApplication sendEvent:] + 71
    13  UIKit                               0x000d7f2e _UIApplicationHandleEvent + 7576
    14  GraphicsServices                    0x0132f992 PurpleEventCallback + 1550
    15  CoreFoundation                      0x00e5c944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    16  CoreFoundation                      0x00dbccf7 __CFRunLoopDoSource1 + 215
    17  CoreFoundation                      0x00db9f83 __CFRunLoopRun + 979
    18  CoreFoundation                      0x00db9840 CFRunLoopRunSpecific + 208
    19  CoreFoundation                      0x00db9761 CFRunLoopRunInMode + 97
    20  UIKit                               0x000cf7d2 -[UIApplication _run] + 623
    21  UIKit                               0x000dbc93 UIApplicationMain + 1160
    22  BlastCalc                           0x00002979 main + 121
    23  BlastCalc                           0x000028f5 start + 53
    24  ???                                 0x00000001 0x0 + 1
)
terminate called throwing an exceptionsharedlibrary apply-load-rules all
(gdb)

我在旧 Xcode 版本和 SDK 中阅读了很多与此相关的修复程序,但是,我无法找到解决我的问题的方法。我对 iOS 不是很精通,对 5 的更改让我很吃惊。

如果有人能指出我将不胜感激的答案的方向。提前谢谢大家。

目前,我正在将我的应用程序杀死,几乎已经决定从头开始重新编码。我曾经尝试过一次,但是整个故事板的事情使它变得困难。

【问题讨论】:

此外,该应用程序根本无法运行。即使从已知有效的快照恢复。干杯 What does this mean? "'NSUnknownKeyException', reason: ... This class is not key value coding-compliant for the key X"的可能重复 【参考方案1】:

我遇到了同样的错误,我通过重新创建以前的连接来修复它。背景是这样的:我创建了一个(iphone)单视图应用程序并添加了一个地图视图到可能视图控制器。我只是运行应用程序,但出现了一些错误。试图修复它,我将地图视图拖到视图控制器以创建插座。同时这并没有解决我删除了网点和所有创建的代码。绕过该错误后,我得到了这个。正如我所说,我通过重新创建地图视图出口来修复它。

现在,这不是一种很好的运作方式。看起来它保留了一些缓存。我很高兴知道如何重置/清理这种情况。

希望对您有所帮助。谢谢!

【讨论】:

【参考方案2】:

我刚刚遇到了同样的问题。我终于通过这样做解决了这个问题:

    对于您的averageChargeLength 标签,请使用 Xcode 界面生成器 (通过选择故事板或 xib)并打开 连接面板。使用情节提要,您只需控制单击 在它上面打开连接面板。 删除所有插座 将鼠标悬停在连接上并单击 小x。 尝试在模拟器中再次运行您的应用程序。对我来说,那 允许我的应用程序毫无例外地运行,但标签没有 更新了。 如果有效,则返回 Xcode 界面生成器并 尝试通过拖动重新创建您要创建的连接 连接回ViewController.h 文件。确保检查 来自连接的重复代码的等效 .m 文件 插入并取出。 尝试再次运行您的应用程序。对我来说,相反 像以前一样失败,它实际上运行了。

之前对我来说失败的原因是我试图将按钮连接到错误的东西。我删除了它所连接的东西,但从未检查过界面生成器以确保连接也消失了。

【讨论】:

为响应干杯。我也到了那个地步。我想我应该用我的解决方案更新我的问题。

以上是关于iOS5 和 XCode4 错误 - 由于未捕获的异常“NSUnknownKeyException”而终止应用程序的主要内容,如果未能解决你的问题,请参考以下文章

未找到 XCode 4 有效的签名身份

IOS 5 上的 Xcode 4.5 错误

由于未捕获的错误导致 iOS 应用程序终止

iOS5 模式登录不再在 XCode 4.2 中启动

由于未捕获的异常“NSInternalInconsistencyException”错误而终止应用程序

iOS 5 上 armv7 的未定义符号:_aes_icm_advance_ismacryp