Get Selected index of UITableView

ios, iphone, nsindexpath, objective-c, uitableview

Solution

NSIndexPath *selectedIndexPath = [tableView indexPathForSelectedRow];

Problem

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.

Original source