user717452
user717452

Reputation: 111

Not Key Value Coding-Compliant

I keep getting this error on my app. The only time I get the error is when I resume the app from a background state. I need some help figuring out where the error lies. It happens every time I go from background to active, no matter what the active ViewController is.

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSCFString 0xc063200> valueForUndefinedKey:]: this class is not key value coding-compliant for the key response.'

Upvotes: 2

Views: 5126

Answers (1)

james_womack
james_womack

Reputation: 10296

It sounds like somewhere in the stack, a non-existant key is being accessed on an NSString. valueForUndefinedKey is part of Key-Value Coding in Objective-C and is part of NSObject. It can be called when valueForKey: doesn't work out on pretty much any object.

I see that exception thrown the most often when either:

  1. A class with a storyboard of XIB file gets refactored and the storyboard or XIB does not.
  2. You have a major memory issue where you're calling a method on a deallocated object and the wrong piece of memory is getting accessed.
  3. It's a network JSON API in action and the method is getting the wrong type of object serialized from JSON (e.g. an NSString instead of NSDictionary).

Setup an exception breakpoint on All Exceptions in Xcode's Breakpoint Navigator so you can find the exact line in your codeNSUnknownKeyException is being thrown on. Press the (+) to bring up the menu.

Breakpoint Navigator

Upvotes: 5

Related Questions