views:

76

answers:

1

I get this error when I try to run my app:

2010-04-29 13:49:01.355 MyApp[56123:207] *** Terminating app due to uncaught
exception 'NSUnknownKeyException', reason: '[<MyViewController 0x5112b10>
setValue:forUndefinedKey:]: this class is not key value coding-compliant for 
the key toolbar.'

MyViewController used to have an IBOutlet called 'toolbar' that connected to a UIToolbar object in a nib. I decided I no longer needed the toolbar or the nib so I removed them from the project. But Xcode seems to still want to refer to 'toolbar'.

Where might the reference to toolbar be if I no longer use a nib? I can synthesize a dummy 'toolbar' property to appease Xcode, but I want to avoid this kind of ugly hack.

EDIT: Strangely, the exception was not raised when I ran the code on the device rather than the simulator. Also, when I use a trivial nib for MyViewController (which contained no toolbar), the exception went away. I am using git and when I went back to run previous commits of my code from before MyViewController even had a toolbar or a nib, those strangely gave the exception as well. That code used to run fine. I do think this exception has something to do with Xcode and the simulator and some kind of left over state from when I removed the unwanted nib from the project.

A: 

Xcode is an IDE. It's not Xcode that's asking your view controller for a toolbar while your app is running.

There are two ways to troubleshoot this:

  1. Set a breakpoint on objc_exception_throw, then run your app under the debugger.
  2. Set a breakpoint on -[NSObject(NSKeyValueCoding) valueForUndefinedKey:], then run your app under the debugger.

Either way, the debugger will break (interrupt) your app when the exception happens. Look at the stack trace to see what sent the valueForKey: message.

Peter Hosey
Thanks, Peter. I will do this, but how do I set these breakpoints? I don't call these functions explicitly in my code.
sam
Use the Breakpoints window in Xcode.
Peter Hosey