title: iphone dev - how to catch exception 'NSRangeException'
body: <p>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:</p>
  
  <blockquote>
    <p>Terminating app due to uncaught exception 'NSRangeException', reason: '-[UITableView scrollToRowAtIndexPath:atScrollPosition:animated:]: row (0) beyond bounds (0) for section (0).'</p>
  </blockquote>
  
  <p>how can I catch this exception? I tried</p>
  
  <pre><code>NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
  
  if (indexPath != nil) {
      [EventTable scrollToRowAtIndexPath:indexPath
                  atScrollPosition:UITableViewScrollPositionTop animated:YES];
  }
  </code></pre>
  
  <p>but it doesn't catch the exception because indexPath is not nil.</p>