As Schreurs already explained you need to implement the UITextFieldDelegate protocol to your viewController (along with UITableViewDataSource), look into those in the documentation to learn more of what you can do with them. But this is more tricky than having distinct UITextFields in your view.
You have to consider the fact that when a cell leaves the visible range of the tableview it will be released or reused. So if for example a cell 1 contains a textfield your write something in it and then scroll to cell 15, you're gonna probably get a cell with the textfield of cell 1 and its contents. If you prepare your cells for reuse, emptying the textFields you have to keep that data somewhere to re-enter it in the proper cell. After all that you're gonna scratch your head what textField is calling your delegate (probably your viewController, so you're gonna have to tag them with a number from which you can extract a row number - i.e. cell.textField.tag = indexPath.row + 100).
So to sum up you want something like this in your viewController
- (void)textFieldDidEndEditing:(UITextField *)textField {
if ([textField.text length] > 0) {
NSUInteger row = textField.tag - 1;
[textFieldValues setObject:textField.text forKey:[NSNumber numberWithInt:row]];
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellId = @"cellId";
TextFieldTableViewCell *cell = (TextFieldTableViewCell *) [tableView dequeueReusableCellWithIdentifier:cellId];
if (!cell)
cell = [[[TextFieldTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId] autorelease];
cell.textField.tag = indexPath.row + 1;
cell.textField.delegate = self;
NSString *value = [textFieldValues objectForKey:[NSNumber numberWithInt:indexPath.row]];
if (value)
cell.textField.text = value;
else
cell.textField.text = @"";
return cell;
}
and then in your TextFieldTableViewCell.h
@property (nonatomic, readonly) UITextField *textField;
and finally in your TextFieldTableViewCell.m
@synthesize textField;
p.s. I was wandering what might happen when the editing textField leaves the visible cell range, and it isn't reused or released... gave me the chills! So didEndEditing should be adequate.