Just set the cell to the tag property. Then you can get this cell by calling it
UITableViewCell *cell = (UITableViewCell *)[self.tableView viewWithTag:tagValue];
then after you have a cell, you can get NSIndexPath, like this
NSIndexPath *indexPath = [self.tableView indexPathForCell:nextResponderCell];
Since you have a UITextField in your custom cell, you can put cell.textField.delegate = self; in
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
data source method. This way you do not have to configure NSNotification in a custom cell. Also in the same method you can mark both text fields of your cells as follows: cell.textField.tag = indexPath.row; and a cell like this cell.tag = indexPath.row;
Now that you have set the UITextField delegate, now you can put this method in your UITableViewController class
- (void)textFieldDidBeginEditing:(UITextField *)textField { CustomCell *cell = (CustomCell *)[self.tableView viewWithTag:textField.tag]; NSIndexPath *indexPath = [self.tableView indexPathForCell:cell]; }
The above UITextField delegate method should get you an indexPath for the cell you selected.
source share