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, there is an alternative way to scroll to the top of the table view, that doesn't depend on the position of the first object. You can simply set the table view's content offset to the top position using the following code:
```objective
[mainTableView setContentOffset:CGPointMake(0, mainTableView.contentInset.top) animated:NO];
```
This code sets the table view's content offset
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