iphone dev - how to catch exception 'NSRangeException'

Posted by Brian on Stack Overflow See other posts from Stack Overflow or by Brian
Published on 2010-05-19T17:18:05Z Indexed on 2010/05/19 17:20 UTC
Read the original article Hit count: 235

Filed under:
|
|

In my app I try to scroll a UITableView to the top once after I updated the content of the table. However, under some circumstance, my table is EMPTY. So I got the following exception:

Terminating app due to uncaught exception 'NSRangeException', reason: '-[UITableView scrollToRowAtIndexPath:atScrollPosition:animated:]: row (0) beyond bounds (0) for section (0).'

how can I catch this exception? I tried

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];

if (indexPath != nil) {

[EventTable scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];

}

but it doesn't catch the exception because indexPath is not nil.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about scrolling