【发布时间】:2013-10-23 03:41:46
【问题描述】:
当我尝试在 iPhone 模拟器上运行我的应用程序时,它崩溃了并且我收到了这个错误:
2013-10-22 20:24:02.367 brainademy[46328:a0b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0xcc6de90> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key ChooseGameViewController.'
*** First throw call stack:
(
0 CoreFoundation 0x01a0d5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x017908b6 objc_exception_throw + 44
2 CoreFoundation 0x01a9d6a1 -[NSException raise] + 17
3 Foundation 0x01451c2e -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
4 Foundation 0x013bdf3b _NSSetUsingKeyValueSetter + 88
5 Foundation 0x013bd493 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
6 Foundation 0x0141f94a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
7 UIKit 0x007a4cd5 -[UIRuntimeOutletConnection connect] + 106
8 libobjc.A.dylib 0x017a27d2 -[NSObject performSelector:] + 62
9 CoreFoundation 0x01a08b6a -[NSArray makeObjectsPerformSelector:] + 314
10 UIKit 0x007a382e -[UINib instantiateWithOwner:options:] + 1417
11 UIKit 0x007a55bb -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 165
12 UIKit 0x00502fcb -[UIApplication _loadMainNibFileNamed:bundle:] + 58
13 UIKit 0x005032f9 -[UIApplication _loadMainInterfaceFile] + 245
14 UIKit 0x00501e9f -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 543
15 UIKit 0x0051642c -[UIApplication handleEvent:withNewEvent:] + 3447
16 UIKit 0x00516999 -[UIApplication sendEvent:] + 85
17 UIKit 0x00503c35 _UIApplicationHandleEvent + 736
18 GraphicsServices 0x0319e2eb _PurpleEventCallback + 776
19 GraphicsServices 0x0319ddf6 PurpleEventCallback + 46
20 CoreFoundation 0x01988dd5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
21 CoreFoundation 0x01988b0b __CFRunLoopDoSource1 + 523
22 CoreFoundation 0x019b37ec __CFRunLoopRun + 2156
23 CoreFoundation 0x019b2b33 CFRunLoopRunSpecific + 467
24 CoreFoundation 0x019b294b CFRunLoopRunInMode + 123
25 UIKit 0x005016ed -[UIApplication _run] + 840
26 UIKit 0x0050394b UIApplicationMain + 1225
27 brainademy 0x0000b01d main + 141
28 libdyld.dylib 0x02e8c725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
大多数情况下,这意味着我的文件所有者中有一些未声明的 IBOutlet 或 IBAction,但事实并非如此。我已经查看了类似这样的所有其他问题,但没有一个有帮助。
ChooseGameViewController IS 已声明,因此这不会导致任何问题,但我尝试将其从文件所有者中解开,当我这样做并运行我的应用程序时,它崩溃了,而不是 ChooseGameViewController颜色游戏视图控制器。我尝试删除我的每一个 ViewController IBOutlets,当我这样做时,我得到了其他 IBOutlets,如标签和按钮,它们显示在错误中,而不是 ChooseGameViewController。我的任何分店旁边都没有错误,就像您通常有一个未声明的分店一样。
我尝试进行干净的构建,但没有成功,并且我的文件所有者已连接到正确的类 (RootViewController)
这个应用程序刚刚运行良好,我今天刚刚打开 Xcode,我开始收到这些错误。
这对于未声明的网点来说不是问题,因为:
- 所有网点已宣布
- 我在文件所有者中没有发现任何错误
- 此错误发生在每个 IBOutlet 中,并且仅限于 IBOutlet
这个错误的原因是什么?
【问题讨论】:
-
看起来这些被发送到 Application 对象而不是视图控制器。这些物品是否连接到正确的位置?
-
是的,一秒钟前它还可以正常工作@borrrden
-
检查“.xib”文件的名称,我认为问题出在 xib 文件名上,并仔细检查“reference Outlets”是否相同。祝你好运。
-
@DipenPanchasara 名字是一样的...我不是在某处导入 AppDelegate 吗?
-
@Domenico 是由于您在控制器中指定的“参考插座”。你在使用 xcode5 吗?那么您需要在
.plist文件中进行相应的更改。并仔细检查名称,Reference Outlets,不需要导入 AppDelegate。
标签: ios objective-c xcode iboutlet