Reputation: 99
How can I display the cell selected from my tableview in NSLog?
Upvotes: 3
Views: 2978
Reputation: 1289
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);
Upvotes: 2
Reputation: 31311
Implement didSelectRowAtIndexPath UITableview delegate and log the indexPath.row.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"selected tableview row is %d",indexPath.row);
}
Upvotes: 4