I have a tableview in my application, into which I am loading different types of cells. This is fine and working well. But now I need to do the pagination. I need to pass the page number to the service as one, two etc and to load that when the 1st page ends. For the first one I am loading the count is 5, after that when scroll ends I need to load the next. I am new to this pagination. Can anybody gave me the direction to follow?I tried like this But it will become an infinite loop `

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *) cell     forRowAtIndexPath:(NSIndexPath *)indexPath
{
    int count1 = [array count];
    NSLog(@"%d",count1);
     NSLog(@"%d",indexPath.section);
    NSLog(@"%d",max);
    NSLog(@"%d",min);

    if(indexPath.section == count1 - 1) // If going to display last row available in your source
    {

        NSLog(@"%d",max);
          NSLog(@"%d",min);


        if(min <= max) 
        {



            [self getmessages:min];
        }
        else
        {
            self.mtableview.tableFooterView = nil; //You can add an activity indicator in tableview's footer in viewDidLoad to show a loading status to user.
        }

    }
}

`

Edit
Report