I can’t figure out why that code is not working for me.
ViewController.h
...
@property (nonatomic, copy) UITextField *textField;
...
ViewController.m
-(void)viewDidLoad
{
[self.textField addTarget:self
action:@selector(textIsChanged:)
forControlEvents:UIControlEventEditingChanged];
}
-(void)textIsChanged:(id)sender;
{
NSLog(@"Changed");
}
When I type something in the textField textIsChanged method is never invoked.
You should declare
textFieldas anIBOutletlike this:or, if you are using ARC (Automatic Reference Counting):
and bind it from the xib file in interface builder.