0

I have a text box, and ctrl+clicked to the .h, and made an outlet and called it usernameTextField. So I'm not even typing out the property - xcode is doing it for me. Here is the text:

@property (weak, nonatomic) IBOutlet UITextField *usernameTextField;

When I try to run the program, it gives me this error -

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

So what am I doing wrong?

sha
  • 17,824
  • 5
  • 63
  • 98
fewaf
  • 145
  • 13
  • Did you change class in this view from UIView to your own class name? – sha Mar 31 '14 at 18:54
  • Has this been connected twice? – JSA986 Mar 31 '14 at 19:02
  • possible duplicate of [This class is not key value coding-compliant for the key](http://stackoverflow.com/questions/3088059/this-class-is-not-key-value-coding-compliant-for-the-key) – Black Frog Mar 31 '14 at 19:04
  • Possible duplicate of [this class is not key value coding-compliant for the key view](http://stackoverflow.com/questions/10152872/this-class-is-not-key-value-coding-compliant-for-the-key-view) also. – Black Frog Mar 31 '14 at 19:06
  • JSA - nope, made sure of that. sha - No, should I do that? – fewaf Mar 31 '14 at 19:10
  • Yes. Otherwise it's trying to instantiate standard UIView and that class has no idea about your usernameTextfield outlet. – sha Mar 31 '14 at 19:12
  • okay I just cleaned the project and it works now. Sorry for wasting your time guys, thanks for the help. – fewaf Mar 31 '14 at 19:13

1 Answers1

1

You should change the class name for this class to your class name and not default UIView. Otherwise in runtime it tries to instantiate UIView class and bind all properties from interface builder to this class. And UIView has no idea about usernameTextField.

sha
  • 17,824
  • 5
  • 63
  • 98