4

I have an Xcode 4 project (iOS 4.3 iPad app) and suddenly I got a NSUnknownKeyException.

I've looked on the internet for the details of this error and almost anyone tells it has to do with references in the xib which are not correct anymore etc. I've checked everything and cannot find the problem anywhere.

This is the error I get:

* Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'

I get the error as soon as I run the app. If I set a breakpoint in the App Delegate in didFinishLaunchingWithOptions it doesn't trigger...

Where does it go wrong? Anyone an idea how to solve this issue? I've tried anything without any luck.

Also, I added a xib with .h and .m files. I've got the same issue then but then it told me what the exception was causing (an property was not set correctly). I removed those .h, .m, and xib files but then I got the error which I've described above.

Thanks in advance!

一二三
  • 21,059
  • 11
  • 65
  • 74
CyberK
  • 1,568
  • 3
  • 31
  • 44
  • http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/CocoaBindings/Concepts/Troubleshooting.html might be helpful. – Martin Wickman May 03 '11 at 21:58

5 Answers5

3

To get an idea where the exception is thrown you could try to obtain a stack trace.
Switch to the Breakpoint Navigator and use the small '+' sign on the bottom left to add an 'Exception Breakpoint'.Use the default settings.
Re-run you app. Xcode should stop 'On Throw' and you can investigate the stack trace.

Thomas Zoechling
  • 34,177
  • 3
  • 81
  • 112
  • Thank you for your response. If I do that, this line is hit as breakpoint: int retVal = UIApplicationMain(argc, argv, nil, nil); I also came to that point by debugging by hand but still no clue what is going on... – CyberK May 03 '11 at 20:47
1

If you are using IB and you have this error, the fix that worked for me was

  • to go too IB
  • right click the view controller
  • and remove my IB outlets

then create them again :)

Marko
  • 20,385
  • 13
  • 48
  • 64
Mike Cottier
  • 109
  • 2
  • 1
0

I encountered this error and I discovered that it was due to having changed the name of the NIB file but not changing its name in the initWithNibName:bundle: call.

Phil
  • 1,030
  • 1
  • 16
  • 22
0

When it says it can't unarchive a key value, I've always gotten that when my resource is missing. So, add your resources back in, and try to fix the error you get then.

sudo rm -rf
  • 29,408
  • 19
  • 102
  • 161
  • Tried that, but still hitting the same error... :( – CyberK May 03 '11 at 20:48
  • @CyberK: You sure you added the original resources back? Without having the originals it's going to be unable to find your connections and link it up with Interface Builder. – sudo rm -rf May 03 '11 at 21:48
  • Well I made a new project, copied all the files over, and voila, it's running like a charm... Very strange... Maybe an xcode 4 bug :P – CyberK May 04 '11 at 06:50
0

Im new to xcode 4 and I was looking at Target : Summary : iPhone / iPod Deployment Info and noticed the Main Interface combobox. I changed it from MainWindow to my root ViewController. Then this exact error started happening right at the start of running.

Switch it back to MainWindow and everything is ok again.

ileff
  • 358
  • 2
  • 5