Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

This class is not a key value coding-compliant

I have created a three files SettingsViewController.h, SettingsViewController.m and SettingsViewController.xib.

I am showing the SwttingsViewController.xib on click of a cell in a row. There is a label and slider on xib file. It works fine. But after creating connections using interface builder. i.e drag-drop from redLabel outlet to my Label on xib file i am getting this error and app terminate.

'[<UIViewController 0x3d636d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key redLabel.'

like image 546
coure2011 Avatar asked Jun 23 '10 07:06

coure2011


People also ask

What is a key value in coding?

Key-value coding is a mechanism enabled by the NSKeyValueCoding informal protocol that objects adopt to provide indirect access to their properties. When an object is key-value coding compliant, its properties are addressable via string parameters through a concise, uniform messaging interface.

What is IBOutlet?

The type qualifier IBOutlet is a tag applied to an property declaration so that the Interface Builder application can recognize the property as an outlet and synchronize the display and connection of it with Xcode. An outlet is declared as a weak reference ( weak ) to prevent strong reference cycles.


2 Answers

I had a similar issue accept my issue was that interface builder hadn't tidied up an item I'd deleted. So it was left in the source code.

Fixed the issue by going into the xib file. Right click on the file and select "Open As" then "SourceCode. THe errore message I got contained : this class is not key value coding-compliant for the key originalField

my error message as you can see gave me the name of the offending item "originalField" in this case it was a text field i'd removed, but interface builder hadn't cleaned up properly.

I went into the source code and searched for originalField and deleted the reference to it, all fixed.

like image 127
Harold Avatar answered Oct 06 '22 01:10

Harold


It looks like the File Owner of the SwttingsViewController.xib has the wrong class. Go inside Interface Builder and change the class of the File Owner to be SettingsViewController. See this page for details about File Owner and UIViewController.

like image 29
Laurent Etiemble Avatar answered Oct 06 '22 01:10

Laurent Etiemble