由于未捕获的异常'NSUnknownKeyException'而终止应用 [英] Terminating app due to uncaught exception 'NSUnknownKeyException'

查看:93
本文介绍了由于未捕获的异常'NSUnknownKeyException'而终止应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用教程编写一个相当简单的应用程序。我今天将应用程序复制到了我的工作计算机它昨晚在我的笔记本电脑上完美运行,但今天我收到了这个错误。我尝试了几乎所有的代码,甚至删除了didFinishLaunchingWithOptions函数中的所有内容,但我仍然得到了这个错误。我甚至没有在任何地方宣布导航栏!我假设在代码之外有某种项目或文件设置是问题吗?

I'm using a tutorial to write a fairly simple app. I copied the app to my work computer today. It was working perfectly on my laptop last night, but today I get this error. I tried gutting nearly all of the code, and even deleted everything in the didFinishLaunchingWithOptions function, but I still get this error. I don't even have a navBar declared anywhere! I assume there's some kind of project or file setting outside of the code that is the problem?

2011-11-22 14:39:32.294 LetsEat[15320:b603] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<LetsEatAppDelegate 0x5a824a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key navBar.'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x00fa45a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x010f8313 objc_exception_throw + 44
    2   CoreFoundation                      0x00fa44e1 -[NSException raise] + 17
    3   Foundation                          0x0079f677 _NSSetUsingKeyValueSetter + 135
    4   Foundation                          0x0079f5e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
    5   UIKit                               0x0021b30c -[UIRuntimeOutletConnection connect] + 112
    6   CoreFoundation                      0x00f1a8cf -[NSArray makeObjectsPerformSelector:] + 239
    7   UIKit                               0x00219d23 -[UINib instantiateWithOwner:options:] + 1041
    8   UIKit                               0x0021bab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
    9   UIKit                               0x0002117a -[UIApplication _loadMainNibFile] + 172
    10  UIKit                               0x00021cf4 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 291
    11  UIKit                               0x0002c617 -[UIApplication handleEvent:withNewEvent:] + 1533
    12  UIKit                               0x00024abf -[UIApplication sendEvent:] + 71
    13  UIKit                               0x00029f2e _UIApplicationHandleEvent + 7576
    14  GraphicsServices                    0x011dd992 PurpleEventCallback + 1550
    15  CoreFoundation                      0x00f85944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    16  CoreFoundation                      0x00ee5cf7 __CFRunLoopDoSource1 + 215
    17  CoreFoundation                      0x00ee2f83 __CFRunLoopRun + 979
    18  CoreFoundation                      0x00ee2840 CFRunLoopRunSpecific + 208
    19  CoreFoundation                      0x00ee2761 CFRunLoopRunInMode + 97
    20  UIKit                               0x000217d2 -[UIApplication _run] + 623
    21  UIKit                               0x0002dc93 UIApplicationMain + 1160
    22  LetsEat                             0x00001c99 main + 121
    23  LetsEat                             0x00001c15 start + 53
)
terminate called throwing an exceptionCurrent language:  auto; currently objective-c
(gdb)

编辑:这是我的代表的最高层。 m档。你可以看到它的全部样板:

This is the top of my delegate.m file. As you can see it's all boilerplate:

#import "LetsEatAppDelegate.h"
//#import "ItemsViewController.h"

@implementation LetsEatAppDelegate

@synthesize window = _window;
@synthesize managedObjectContext = __managedObjectContext;
@synthesize managedObjectModel = __managedObjectModel;
@synthesize persistentStoreCoordinator = __persistentStoreCoordinator;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    [self.window makeKeyAndVisible];
    return YES;
} 

我删除了项目中的所有其他文件但仍然出现此错误。

I removed every other file in the project and still get this error.

编辑2

现在看来,我只收到此错误我的工作机器。完全相同的文件在我家用笔记本电脑上运行完美。相同版本的XCode(4.2.1)

As it now stands, I only get this error on my work machine. The exact same files run perfectly on my home laptop. Same version of XCode (4.2.1)

推荐答案

修复 - 转到iOS模拟器>重置内容和设置

Fixed - went to iOS Simulator > Reset Content and Setting

这篇关于由于未捕获的异常'NSUnknownKeyException'而终止应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆