我正在使用教程编写一个相当简单的应用程序.我今天将应用程序复制到了我的工作计算机 它昨晚在我的笔记本电脑上完美运行,但今天我收到了这个错误.我尝试了几乎所有的代码,甚至删除了didFinishLaunchingWithOptions函数中的所有内容,但我仍然遇到了这个错误.我甚至没有在任何地方声明导航栏!我假设代码之外的某种项目或文件设置是问题?
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)
Run Code Online (Sandbox Code Playgroud)
编辑:这是我的delegate.m文件的顶部.你可以看到它是所有的样板:
#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;
}
Run Code Online (Sandbox Code Playgroud)
我删除了项目中的所有其他文件仍然出现此错误.
编辑2
就目前而言,我只在工作机器上出现此错误.完全相同的文件在我家用笔记本电脑上运行完美.相同版本的XCode(4.2.1)
Nit*_*bur 36
重置内容和设置不起作用.
这是我深夜2小时的浪费时间:
我已将界面构建器中的UIControl插座连接到xib所有者的IBOutlet.出于某种原因,IBOutlet已从所有者中删除,但对插座的引用仍悬挂在xib中.这总是会给我错误
"Terminating app due to uncaught exception 'NSUnknownKeyException'"
Run Code Online (Sandbox Code Playgroud)
获得的经验教训:在实施中删除任何vars插座时,请务必取消IB中相应的连接
更新:(2015年1月26日)
接口生成器或笔尖的行为方式是有充分理由的,今天我意识到了原因.
如果您在TheBaseClass中有一个IBOutlet,并且您在TheSubClass的故事板中有一个nib或场景,则有两种方法(hacks)可供您连接此插座:
在Identity Inspector下,将"Custom Class"标识符命名为TheBaseClass,连接插座,然后将"Custom Class"部分中的Class name设置为TheSubclass
在TheSubclass代码中添加IBOutlet,将其连接到nib中的ui元素,在TheBaseClass中添加IBOutlet代码,在TheSubClass中删除该代码
当我遇到这个答案时,它刚刚落实到位,为什么Apple会让这个悬空参考问题保持不变.因为,这不是一个bug.这是一个功能.
Rac*_*elD 10
我遇到了这个问题,发现我设置了"主界面",这引起了一个问题.
要更改此设置,请单击您的项目(在左侧文件浏览器中).中心区域现在应显示项目设置的"摘要".这与您更改iOS应用程序目标或支持的设备方向的区域相同.在"iPhone/iPod部署信息"部分下,清除"主界面"下拉列表,将其留空.这为我解决了这个问题.
祝好运.
问题出在你的nib文件中.从LetsEatAppDelegatenavBar到旧版连接.
我不确定你的应用是如何设置的,LetsEatAppDelegate你的一个nib文件中可能有一个对象,或者可能有一个文件所有者将类设置为LetsEatAppDelegate
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
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:
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
54988 次 |
| 最近记录: |