Error Objective C forControlEvents
I am new to objective C and am having a problem with the following line. The error is: "Passing argument 3 of 'addTarget;action:forControlEvents:' makes integer from pointer without a cast." The wierd thing is that I get the warnings and everything works fine on the IPAD but on the simulator it works sometimes and other times it does not work. I have a textfield in a tableviewcell, when the user types it sends what they typed to a 开发者_StackOverflow中文版variable.
[textField addTarget:self action:@selector(setFilterCriteria:) forControlEvents:UITextFieldTextDidChangeNotification];
Here is the IBAction:
- (IBAction)setFilterCriteria:(id)sender {
UITextField *senderTextField = (UITextField *)sender;
appDelegate.setFilterCriteria = senderTextField.text;
}
You're specifying the wrong kind of thing for the control event.
UITextFieldTextDidChangeNotification
is a notification name, not a control event type. You want one of the UIControlEvent...
constants, like UIControlEventValueChanged
.
(You're seeing the warning because the notification names are NSString*s, and the expected type of that argument is a defined numeric constant.)
精彩评论