Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get a textDidChange (like for a UISearchBar) method for a UITextField?

How can I get a textDidChange method for a UITextField? I need to call a method every time a change is made to a text field. Is this possible? Thanks!

like image 581
Jonah Avatar asked Dec 17 '09 04:12

Jonah


1 Answers

You can use the UITextFieldTextDidChangeNotification to call a method whenever the text field changes. Add this to your init:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textDidChange:) name:UITextFieldTextDidChangeNotification object:nil];
like image 189
Chris Long Avatar answered Nov 14 '22 09:11

Chris Long