How can I display the cell selected from my tableview in NSLog?
Asked
Active
Viewed 2,972 times
2 Answers
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
-
as of Xcode 5+ NSLog(@"selected tableview row is %ld",(long)indexPath.row); should do the trick. – tony.stack May 15 '14 at 20:53
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