I thought this would be pretty simple but apparently it isn't, at least not to me. I have a UITextField
declared in my .h
file and declared its property, as well as an IBAction
to clear the text within the field.
IBOutlet UITextField *textField1;
@property(nonatomic, retain) UITextField *textField1;
-(IBAction)clearText:(id)sender
Then in my implementation file (.m
) this is how I've written the method to clear the text.
-(IBAction)clearText:(id)sender {
textField1.text = NULL;
}
But nothing happens when I press the button in the simulator. Why?
Did you actually connect the outlet?
Also I'd suggest using nil
or @""
instead of NULL