Search code examples
iosobjective-cxcodeiboutlet

This class is not key value coding-compliant


When I try to run my application on the iPhone simulator, It crashes and I get this error:

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

Most of the time, this is going to mean that I have something in my File's owner, an IBOutlet or IBAction that is not declared, yet this is not the case. I have looked at every single other question like this and none of them have helped.

ChooseGameViewController IS declared, so that shouldn't cause any problems, but I tried unhooking it from the File's owner, and when I do, and run my app, It crashes and instead of ChooseGameViewController it's ColorGameViewController. I tried removing every single one of my ViewController IBOutlets, and when I did that, I got other IBOutlets, like labels and buttons, that showed up in the error instead of ChooseGameViewController. I get no errors next to any of my outlets, like you usually would if you had an non-declared outlet.

I tried making a clean build, but that didn't work, and my File's owner is hooked up to the correct class (RootViewController)

This app was working fine just a while ago, and I just opened up Xcode today and I started getting these errors.

This is not a problem with non-declared outlets, because:

  • All the outlets ARE declared
  • I get no errors in the file's owner
  • This error happens with every single IBOutlet, and IBOutlets only

What is the cause of this error?


Solution

  • I fixed it by creating a new Xcode project and copying everything over, which makes me think it had something to do with the me trying to add support for iPad.

    This happens whenever I try to do this, even making a new application, making it universal, and making the new .xib file for iPad, and hooking it up via the project manager.

    Even when I remove support for iPad the error above still shows, I think I have to do something with just changing the view controller using code.