Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

xcode

ios4

ios5

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

So I have been trying what other people have been saying with similar problems. I have tried getting rid of every mention of landscapeView in the project, including the Connections in the FIle's Owner in the ViewController_iPhone.xib and then I started fresh by making outlets in the super class ViewController (since I want to use landscapeView and portraitView for iPad also) then I set up connections in ViewController_iPhone.xib and ViewController_iPad.xib to the UIView named Landscape in each respectively, and I still get this error.

I'm just starting out in app development so I'm trying to make a template for an app that is supportive of all orientations on both iPhone and iPad. Thanks for any help

EDIT: Here is a link to all my app delegate h and m and main.m : I am getting the Applications are expected to have a root view controller at the end of application launch error

EDIT 2: So I also tried to make landscapeView a property of ViewController and I made a setter method in ViewController.m but it still has the same problem.

like image 920
Peter P Avatar asked Dec 01 '22 06:12

Peter P


2 Answers

I've found the most common place this error happens is when you instantiate a view from a xib from within a class that is not the xib's owner.

What I mean by this is you might be calling something similar to this:

[[NSBundle mainBundle] loadNibNamed:@"MyView" owner:self options:nil];

You're changing the owner, so you have to be sure that the class that self refers to has all the IBOutlet properties needed by "MyView". Usually this is done in Interface Builder, but in this case you're setting your owner programmatically, which means you can't make the connections in IB. When the IBOutlets aren't there, the app tries to make those connections and fails, giving the error you see.

My advice (without knowing any more info than you've given so far) is to check to see if you've made this call without having the proper IBOutlets.

like image 146
Aaron Avatar answered Dec 06 '22 02:12

Aaron


I had to remove the NIB or XIB (or whatever they are this iteration) for the Main Interface.

It sure would be nice if Apple fully tested the broken software before unleashing it on the unsuspecting public. They could have handled the problem in any number of ways; but instead they chose a runtime crash and obscure [meaningless] error message.

enter image description here

like image 40
jww Avatar answered Dec 06 '22 02:12

jww