Tom John
Tom John

Reputation: 99

Display the tableview row selected in NSLog

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

Upvotes: 3

Views: 2978

Answers (2)

SPA
SPA

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

Shamsudheen TK
Shamsudheen TK

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

Related Questions