4

I am making an App in Xcode and i have been getting the error

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

recently. I have been searching for hours and i cannot seem to find an answer that matches my case. This error happened when i added new objects and removed some objects in the .h file but i have double-triple-quadruple checked that every single outlet is connected rightly. Nothing is phantom connected or not connected, everything is all good. When i tried to remove the key mentioned in the error code, it went to the next key and it kept on, basically every single connection is bad. I have connected the view properly (i think) since when i add new outlets in the .h file i am able to see it in the xib file and connect it, but every time i open the app i still get this error.

i recently changed the view controller id thingy to XcodeProjectViewController and i have checked all my files (h, m and xib) to see that they are matching.

Dan F
  • 17,654
  • 5
  • 72
  • 110
Simon Andersson
  • 365
  • 3
  • 15
  • 1
    You probably had an `IBOutlet` named `achiev` and hooked it up in IB, and then later deleted the property, but that hookup remains in IB, you have to go in and delete it – Dan F Mar 06 '13 at 20:01
  • To make things easier you can right click on your xib/storyboard file in the project navigator and select "open as->source code" and search for "achiev" to find the offending linkage – Dan F Mar 06 '13 at 20:05
  • I have had that into mind and i have checked that but as i said i have double checked that i do infact have all the IBOutlets in the H file and Xib file connected, everything that is connected in the Xib file has a line of code in the .h file, and if i remove one connection and its reference in the xib file, it goes on to the next key available and gives an error that the next key is also bad, but it is definately properly connected. Unless there is another way than the "Connection inspector" in the xib file to see connections – Simon Andersson Mar 06 '13 at 20:05
  • Did you try opening as source code and see if there is an outlet entry for the "achiev" property? – Dan F Mar 06 '13 at 20:13
  • I opened it as source code, pressed cmd+f and typed in achiev and indeed i got several matches – Simon Andersson Mar 06 '13 at 20:14
  • Do you have that property declared/synthesized in your code somewhere? More importantly, in the correct place – Dan F Mar 06 '13 at 20:15

1 Answers1

13

I encountered this error message in my latest app, Label Dispenser PRO. It is pretty annoying because all codes seems ok (because they are).

After a few hours of investigating, it turns out (for my case) the problem was I specified (accidentally?) XIB files as Main Interface for the "iPad development info" section in Target's Summary area. Here's the pic to illustrate this location: enter image description here

Deleting this field solved the problem. I guess this happens because compiler is confused since I was manually presenting the XIB based on if statement evaluating "if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)" in the AppDelegate.

Hope this helps someone. Cheers.

GeneCode
  • 7,545
  • 8
  • 50
  • 85
  • This was my problem (Xcode 5) and the clue is that the exception happens in UIApplication, not the view controller attached to the XIB. – macasas Nov 15 '13 at 11:56
  • 1
    Hallelujah! You are a life-saver. I had the same issue in XCode 5 and would never have figured this out by myself. – Simo A. Nov 19 '13 at 19:19