Here is the code I\'m using:
if (appDelegate.currentMainIndexPath != nil /* && doesPathExistInTableView */)
{
[tblView scrollToRowAtIndexPath:appDele
This is how you do it:
indexPath.row < [self.tableView numberOfRowsInSection:indexPath.section]
In context:
if (indexPath.row < [self.tableView numberOfRowsInSection:indexPath.section]) {
[self.tableView scrollToRowAtIndexPath:indexPath
atScrollPosition:UITableViewScrollPositionTop
animated:YES];
}
Inserted into your code:
if (appDelegate.currentMainIndexPath != nil &&
indexPath.row < [tblView numberOfRowsInSection:indexPath.section]) {
[tblView scrollToRowAtIndexPath:appDelegate.currentMainIndexPath
atScrollPosition:UITableViewScrollPositionTop
animated:NO];
appDelegate.currentMainIndexPath = nil;
}
You can also use UITableView's numberOfRowsInSection
method.