In my table view I have to scroll to the top. But I cannot guarantee that the first object is going to be section 0, row 0. May be that my table view will start from section number 5.
So I get an exception, when I call:
```[mainTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
```
Is there another way to scroll to the top of table view?
You're right that if the first object isn't in the first section, then attempting to scroll to section 0, row 0 will result in an exception. However, scrolling to the top of the table view isn't necessarily limited to that specific index path. Instead, you can scroll to the top of the content, regardless of where the first object is located, by invoking the `scrollToTop` method of `UITableView`:
Yes, you can scroll to the top of the table view without having to know that the first row is in section 0 and row 0.
You can set the content offset of the table view directly to scroll to the top. Here's how you can do it:
1. Get the current content offset of the table view using the following code:
```
CGPoint currentContentOffset = self.tableView.contentOffset;
```
2. Set