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.
'
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With