Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setValue:forUndefinedKey:]:

FinalViewWithSending *newView = [[FinalViewWithSending alloc]initWithNibName:@"FinalViewWithSending" bundle:nil];
newView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:newView animated:YES]; //it crashes here with a thread 1 error, SIGABRT error..

It says:

"Terminating app due to uncaught exception 'NSUnknownKeyException', 
reason: '[<FinalViewWithSending 0x1bef70> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key loginButton.'"

There is no variable called loginButton so Im not sure why i am getting an error...

Thank you

like image 629
Szwedo Avatar asked Mar 30 '12 21:03

Szwedo


7 Answers

Phillip Mills is correct.

The answer here, for anyone searching, is to edit the storyboard and remove any link to the undefined key specified. You have to edit the storyboard file in an external editor: Right click on the storyboard listing in the hierarchy and then click on "show in finder" or what have you. Open in a text editor, remove said links by searching, save and return to Xcode. No more issue.

This happens when you remove something from the view controller improperly.

like image 29
timquinn Avatar answered Nov 15 '22 17:11

timquinn


You are getting the error because there is no property called loginButton. Check your .xib file. There is almost certainly a bad link to a FinalViewWithSending object (likely File's Owner) that specifies loginButton even though it doesn't exist in the class code.

like image 139
Phillip Mills Avatar answered Nov 15 '22 17:11

Phillip Mills


Agreeing here - Phillip Mills is correct.

Someone mentioned opening the storyboard up in a text editor - this isn't necessary.

Just click on the storyboard, go to the Connections Inspector. If you've got a problematic outlet, you'll see an exclamation marker next to the outlet. Delete it.

like image 30
Snowcrash Avatar answered Nov 15 '22 17:11

Snowcrash


Since this is the first search result for this error, I decided to write an answer for rookies like me.

You are going to get this error if you have Ctrl dragged connections from Buttons which generates code in your ViewController and then you delete just the code without removing the connection.

I got this error because I had accidently added a few buttons as Outlets, when I wanted to add them as Actions. I deleted the code that got generated but the bad connections were still there.

To find and remove them, View->Utilities->Show Connections Inspector

Then click through the different buttons you have and click the x to remove the bad connections.

enter image description here

like image 23
Joshua Dance Avatar answered Nov 15 '22 15:11

Joshua Dance


If you have any localizations, search for bad links in all the storyboards (expand storyboard to find localized storyboards).

This was my situation. I was looking for bad links in one storyboard and they were in the localized one.

like image 21
Yan Arbanov Avatar answered Nov 15 '22 15:11

Yan Arbanov


You can try the way I used to fix my setValue:forUndefinedKey:]: problem.

http://i.stack.imgur.com/PDjub.png

like image 32
James Wang Avatar answered Nov 15 '22 16:11

James Wang


I had the same problem:

I had previously made a connection using storyboards from a textfield to a header file. I later decided I wanted to rename my object's connection, unfortunately, I didn't break the connection properly. If this problem was the same as mine, a connection existed to a button previously, and the code in the header was deleted, but the connection was not.

Check the object connections in the view you are segueing to.

like image 24
kjbradley Avatar answered Nov 15 '22 15:11

kjbradley