this class is not key value coding-compliant for the key view

IphoneObjective CIosXcode

Iphone Problem Overview


i´m very new to xcode... a made an app (simple calculator) work´s pretty good (on simulator and device). When i set the main interface in the summary options from Target, i get the following error when starting the simulator:

> 2012-04-14 12:17:27.123 CalcTest[27550:f803] *** Terminating app due > to uncaught exception 'NSUnknownKeyException',

> reason: > '[<UIApplication 0x6a14650> setValue:forUndefinedKey:]: this class is > not key value coding-compliant for the key calculatorScreen.' > > *** First throw call stack: (0x12db022 0x18f8cd6 0x12daee1 0xcc2022 0xc33f6b 0xc33edb 0xc4ed50 0x53671a 0x12dcdea 0x12467f1 0x53526e > 0x536eb7 0x313ce1 0x313ff8 0x31317f 0x322183 0x322c38 0x316634 > 0x27fcef5 0x12af195 0x1213ff2 0x12128da 0x1211d84 0x1211c9b 0x312c65 > 0x314626 0x1bad 0x1b15 0x1) terminate called throwing an > exception(lldb)

to find the problem, i started a new view based project.

Run the empty new project on the simulator -->works,

But when I set the main interface, to ViewController, in the summary -->the Simulator crash with

> 2012-04-14 12:11:17.492 crash[27494:f803] *** Terminating app due to uncaught > exception 'NSUnknownKeyException', reason: > > '[<UIApplication 0x6a6f4b0> setValue:forUndefinedKey:]: this class is > not key value coding-compliant for the key view.' > *** First throw call stack: > > (0x13c7022 0x1558cd6 0x13c6ee1 0x9bf022 0x930f6b 0x930edb 0x94bd50 > 0x23371a 0x13c8dea 0x13327f1 0x23226e 0x233eb7 0x10ce1 0x10ff8 0x1017f > 0x1f183 0x1fc38 0x13634 0x12b1ef5 0x139b195 0x12ffff2 0x12fe8da > 0x12fdd84 0x12fdc9b 0xfc65 0x11626 0x1d4d 0x1cb5) terminate called > throwing an exception

is there a solution for the problem?

Iphone Solutions


Solution 1 - Iphone

If you have a control in your nib (xib file) that is linked to a property (IBOutlet) or method (IBAction) in your view controller, and you have either deleted or renamed the property or method, the runtime can't find it because it has been renamed and therefore crashes.

In your case, you have set the Main Interface property of the project to your ViewController.nib. This is a problem because the only nibs that should be used as Main Interface should have UIWindows in them and the File Owner in that nib should be set to the AppDelegate. The UIWindow in the nib should be linked to the File Owner's (AppDelegate) window property. Because you set that with a nib without the traits the runtime was looking for, it gives you this error.

The solution is to leave the Main Interface blank as you do not have to set up UIWindows manually anymore.

Solution 2 - Iphone

Just had the same problem and fixed it by right Control-Clicking controls in the xib file to see referencing Outlets. Turned-out that some of the control were still referencing and older name and causing this error to happen.

Solution 3 - Iphone

if you get a message similar to:

  • Terminating app due to uncaught exception 'NSUnknownKeyException', reason:

'[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key

click the add (+) at the left bottom corner of the BreakPoint navigation area, choose 'add Exception Breakpoint', since it is crashing because of 'NSUnknownKeyException', and opt for 'All'. Run the program. The program stops at the first exception.

Solution 4 - Iphone

try this, select File's Owner then click on the "Connection Inspector" (upper on the top of right pane), you will see all the outlets. Look for any sign like this (!) you will find it on the small circle which indicates a missing outlet, all you have to do is linking it properly or remove the outlet.

Solution 5 - Iphone

Try this,

Go to Target=>Build Phases=>Compile Sources

Then include 'calculatorScreen.m'

Solution 6 - Iphone

I was facing the same problem. In my case i had renamed the text label in .h file. So there was multiple reference for that label in my main.storyboard file. Once i removed old reference my code started working.

Solution 7 - Iphone

![][1]

Please check your target membership [1]: http://i.stack.imgur.com/ooJVl.png

select first option.this may help to others

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionhugobossView Question on Stackoverflow
Solution 1 - IphoneJoseph DeCarloView Answer on Stackoverflow
Solution 2 - IphonepbeaumierView Answer on Stackoverflow
Solution 3 - IphoneYohannes WoldemariamView Answer on Stackoverflow
Solution 4 - IphoneDiaa DenView Answer on Stackoverflow
Solution 5 - IphoneVinayView Answer on Stackoverflow
Solution 6 - IphoneYo SolankiView Answer on Stackoverflow
Solution 7 - IphoneKrutarth PatelView Answer on Stackoverflow