setValue: forUndefinedKey:] ...">

Error: application termination due to undetected exception "NSUnknownKeyException", reason: "[<UIApplication 0x6887a30> setValue: forUndefinedKey:]

Full error: the application terminated due to an unmasked exception "NSUnknownKeyException", reason: "[setValue: forUndefinedKey:]: this class is not a key value compatible with the encoding for the key.

So, I tried that other people spoke with similar problems. I tried to get rid of any mention of landscape design in the project, including the connections in the FIle owner in ViewController_iPhone.xib, and then I started a new one by creating a weekend in the superclass of ViewController (since I want to use LandscapeView and PortraitView for iPad as well) then I set up the connections in ViewController_iPhone.xib and ViewController_iPad.xib in a UIView named Landscape respectively, and I still get this error.

I'm just starting to develop applications, so I'm trying to create a template for an application that supports all orientations on the iPhone and iPad. Thanks for any help

EDIT: here is a link to all my delegates h and m and main.m: I get that it is expected that the root view controller will appear in applications at the end of the application, a launch error

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

+4
source share
4 answers

I found the most common place where this error occurs when you create a view from xib from a class that does not own xib.

I mean, you can call something similar to this:

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

You change the owner , so you must be sure that the class to which self belongs has all the IBOutlet properties necessary for "MyView". This is usually done in Interface Builder, but in this case you programmatically set your owner, which means that you cannot establish connections in IB. When IBOutlets does not exist, the application tries to make these connections and does not work, indicating an error.

My advice (not knowing more information than you have given so far) is to check if you made this call without proper IBOutlets.

+9
source

I needed to remove the NIB or XIB (or whatever, this is an iteration) for the main interface.

Of course, it would be nice if Apple fully tested the broken software before untying it on an unsuspecting public. They could solve the problem in any way; but instead they chose an alarm error message and an obscure error message.

enter image description here

+9
source

The following are two main reasons:

  • Your iboutlet may break, please check the storyboard or IB.
  • If you do not select a module for a custom class, see the storyboard section.
+1
source

I found that I deleted the WebView in viewcontroller.h, but did not delete the xib file pointing to this WebView!

0
source

Source: https://habr.com/ru/post/1400321/


All Articles