3

How can I display the cell selected from my tableview in NSLog?

Flexo
  • 87,323
  • 22
  • 191
  • 272
Tom John
  • 99
  • 1
  • 7

2 Answers2

4

Implement didSelectRowAtIndexPath UITableview delegate and log the indexPath.row.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    NSLog(@"selected tableview row is %d",indexPath.row);
}
Shamsudheen TK
  • 30,739
  • 9
  • 69
  • 102
2

If you want to show what is being displayed in the cell, e.g. on its textLabel, use this in the didSelectRowAtIndexPath:

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSLog(@"selected cell textLabel = %@",cell.textLabel.text);
SPA
  • 1,279
  • 8
  • 13