Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

justfred

macrumors newbie
Original poster
May 8, 2009
21
0
If I have multiple UITextFields and use Interface Builder to call an IBAction update() for Editing Did End, is there an easy way to determine what text field was just edited from within update()?

Other creative ways I'm considering:
subclass UITextField
create a unique IBAction for each text field
override textViewShouldEndEditing

but which is best? or is there a magic convenience method I missed?
 
Is your update defined like so?:
Code:
- (IBAction)update:(id)sender;
If so, the sender parameter will contain the UITextField that triggered the action, and you can use that in your logic, normally along the lines of this:
Code:
- (IBAction)update:(id)sender {
    UITextField *theTextField = (UITextField *)sender;
    if (theTextField == textField1) {
        // do stuff for the first text field here
    ...
}
 
You can set the tag in the textField to the row or some other value and then check that with the sender in your action. Also if you subclass UITableViewCell you can make the cell the delegate and have the cell call back to your view controller and then pass back whatever info you like. You can easily add the row or indexPath to this callback if you want.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.