Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The class is not key value coding-compliant for the key [duplicate]

I'm currently learning how to code for iPhone though the Beginning iPhone 4 development book by Jeff LaMarche but have come across a problem that I cannot seem to see where the problem lies. I have read on many forums saying that this is a problem with IBOutlets not being connected correctly but I have tried it many times and the problem does not go away so I'm here asking for help.

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x4b3c2a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key datePicker.'
like image 466
Hong Yi Avatar asked May 09 '11 04:05

Hong Yi


People also ask

How do I fix this class is not key value coding compliant for the key?

You can fix the error by breaking the connection that is causing the problem. Simply click the X to delete the outlet. Then you can go back to the View Controller and simply recreate the connection. Just hold the control key and drag and drop the mouse pointer to the outlet you want to connect.

What is key value coding?

About Key-Value 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.


1 Answers

Open your nib file and check whether datepicker outlet is connected to your UIDatepicker .This problem arises when referncing outlet not set.

Please follow this steps 1. Open your MainWindow nib. 2. Select DataPickerViewController. 3. Change Its Class(Alt+4) to DataPickerViewController (Currently it's UIViewController). 4.Save the Nib and run, will work.

like image 151
itZme Avatar answered Oct 14 '22 03:10

itZme