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?
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
Here is the code that I am currently using.

```
[mainTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:currentIndex inSection:currentSection] atScrollPosition:UITableViewScrollPositionTop animated:NO];
if(currentSection > 0 && currentIndex == 0)
{
    NSInteger offset = mainTableView.contentOffset.y;
    [mainTableView setContentOffset