clearing a UITextField when the user starts typing

There is a delegate method called

textFieldDidBeginEditing:(UITextField*) tf{
  tf.startedEdinting = YES;
}

textFeildDidEndEditing: (UITextField*) tf {
  tf.startedEditing = NO;
}

Add startEditing in a category to UITextField.

Then if value changes clear the field:

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
 if (textField.startEditing){
  textField.text = string;
 } else {
  textField.text = [textField.text stringByReplacingCharactersInRange:range withString:string];
 }
}

You can add the property to the UITextField category in the following way:

.h

@property (nonatomic, assign) BOOL startEditing;

.m

@dynamic startEditing;

- (void) setStartEditing:(BOOL)startEditing_in{ 
NSNumber* num = [NSNumber numberWithBool:startEditing_in]; 
objc_setAssociatedObject(self, myConstant, num, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 
} 
- (BOOL) startEditing{ 
NSNumber* num = objc_getAssociatedObject(self, myConstant); 
return [num boolValue]; 
}