sender修改UITextField的值

在视图中有两个UITextField都链接到方法中

- (IBAction)showContactPicker:(id)sender;

现在根据给定的sender修改文本域的值,应该怎么实现?

在两种方式可以知道这个sender是哪个UITextField
第一种:
在头文件中定义变量

UITextField *tf1;
UITextField *tf2;

- (IBAction)showContactPicker:(id)sender {
     UITextField *tf=(UITextField *)sender;
     if (tf==tf1) {
             ////....to do 
     }else if (tf==tf2) {
            ////.....to do 
     }
}

第二种:
根据tag来判断是哪个UITextField

在代码中分别设置这两个UITextField的tag值

textField1.tag=8;
textField2.tag=9;

- (IBAction)showContactPicker:(id)sender {
      UITextField *tf=(UITextField *)sender;
      switch(tf.tag) {
             case 8:
             break;
             case 9:
             break;
       }
}