Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x9e37580> setValue:forUndefinedKey:]: [duplicate]

Tags:

xcode

iphone

ipad

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.

like image 903
Simon Andersson Avatar asked Dec 12 '22 17:12

Simon Andersson


1 Answers

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.

like image 101
GeneCode Avatar answered May 30 '23 15:05

GeneCode