Why is my app crashing - 'NSUnknownKeyException'? - xcode

Im having an issue with Xcode where its crashing on references to old variables which I have deleted, the error message is
*** Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[<mydoncaster.OptionsView 0x11fd94eb0> setValue:forUndefinedKey:]:
this class is not key value coding-compliant for the key restaurantLabel.'
I don't know why its moaning about restaurantLabel when that no longer exist in the specific view controller, I can delete everything out of the view controller and from the storyboard and build it all again and it still brings up the error, I've also tried building and cleaning my code but it still happens, is this a saving issue or something else.

Search for "restaurantLabel" in your storyboard.
There should be an outlet somewhere in "Referencing outlets" section, which you've forgotten to delete.

Related

Error when clicking any UI element in Xamarin.iOS

I have an issue with an iOS app I'm working on (https://github.com/nodoid/WeatherApp). It builds and deploys fine but when you hit any UI element that isn't a label, it crashes with an error such as
ViewController btnGetWeather unrecognised selector sent to instance
Error: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: ViewController btnGetWeather unrecognised selector sent to instance
It's been a long time since I've done anything with iOS native (I was still using xibs!). It looks like everything is correct on the storyboard but I'm at a loss as to why this is happening given everything builds.
I've done the usual trick of deleting the obj folder in the iOS project, but still get this issue.
I downloaded your code to try it out. When I click the button, the error message :Name: NSInvalidArgumentException Reason: Application tried to present modal view controller on itself. Presenting controller is <UIAlertController: 0x7fb648008a00>.
I found the reason for this problem: In the ShowError method of your ViewController.cs, you use the alert.PresentViewController() method, you need to change the alert of this line of code to "this.PresentViewController()".

'Could not instantiate class named NSLayoutConstraint' while auto layout is disabled

My application is crashing on iOS 5 when I call presentModalViewController on a new view with the error:
Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named NSLayoutConstraint'
I know that this error should be fixed by unchecking auto layout, but it isn't. I unchecked it in all my nibs.
The very puzzling part is that using a view I created one month ago, there is no crash, but using one that I created today, it crashes.
Is there another setting that I should know about?
I'm using XCode 4.5.2, with SDK 6.0, and deployment target 5.0.
I guess you would have solved the problem by now.
But for others who would stumble into this post, please check this post: https://stackoverflow.com/a/13201690/942966

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

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.
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.
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.
Two main reason is follow
your iboutlet may break please check in storyboard or IB.
if you don't select module for custom class, see into your storyboard.
What I found is I deleted a WebView in viewcontroller.h , but haven't delete the xib file that point to this WebView !

Can't run XCode templates

I'm new to iPhone development and have run in to a problem.
This is what I do;
Create a new project (any type, unchecking Use storyboards).
Running it.
This is the error I get;
Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[<UIApplication 0x6a35470> setValue:forUndefinedKey:]:
this class is not key value coding-compliant for the key view.'
I haven't added any code at all yet, so this suprises me a bit.
Should I not be able to run an 'empty' app?
When I use storyboards I can run the project, add all the objects and code I want and run it just fine.
It just feels like I'm missing something really simple.
Thanks in advance!
Yes, you're missing something really simple.
Select your project on top left, select your target and check where it says:
Main Storyboard:
Main Interface:
You have to have a window to start up with....

'NSUnknownKeyException': this class is not key value coding-compliant for the key

I got this message:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<FirstViewController 0x601b610> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key newCell.'
How do I solve it?
That is generally due to deleting an IB object but forgetting to delete it's links.
IE deleting a UIScrollView but forgetting to delete how it used to link into UIView through an IBOutlet.
Had the same problem earlier today... found the answer here: http://www.iphonedevsdk.com/forum/iphone-sdk-development/47036-setvalue-forundefinedkey-class-not-key-value-coding-compliant-key.html
In case that helps someone else, after checking and updating all your links between the views and the matching IBOulet, Cleaning you project can sometimes fix this issue.

Resources