Ivan Diaz
Ivan Diaz

Reputation: 41

Calling textfieldshouldreturn causes an exception to be called

The exception thrown is: 2012-09-21 00:46:56.885 Colors[3032:c07] -[UITextField value]: unrecognized selector sent to instance 0x718cce0 2012-09-21 00:46:56.887 Colors[3032:c07] *

instance 0x718cce0 is the textfield object in:

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
} 

The exception is thrown when we return YES and even if we return NO.

Upvotes: 0

Views: 201

Answers (2)

Apple_iOS0304
Apple_iOS0304

Reputation: 1102

I believe there is something that corrupts your memory on run time. You can try and check few things that might be causing such an exception. Make sure your UITextField confirms to UITextFieldDelegate. Right click on the UITextField to see if it attaches any IBAction that does not exist in its context. Set the delegate of the UITextField in the viewDidLoad.

I hope it helps you.. If it still doesn't please try to brief a bit more on your issue. Happy Coding. Cheers!!

Upvotes: 0

David Hoerl
David Hoerl

Reputation: 41642

You asked the textField for its value - it has no such method or property. Ask it for its 'text' property.

Upvotes: 1

Related Questions