Search code examples
iosobjective-ciphoneuitableviewnsindexpath

Get Selected index of UITableView


I want to have selected index for UITableView. I have written following code:

NSIndexPath *index = [NSIndexPath indexPathForRow:1 inSection:0];
[tableView scrollToRowAtIndexPath:index 
                 atScrollPosition:UITableViewScrollPositionTop 
                         animated:YES];

This always work for 1st item. I want to have selected index in indexPathForRow.

Please help. Thanks.


Solution

  • NSIndexPath *selectedIndexPath = [tableView indexPathForSelectedRow];