title: app crash at tableview:reloadrowsatindexpaths
body: <p>I have a custom tableview cell and am getting data from the network 10 at a time. As users scroll down it fetches 10 more and displays the content. </p>
  
  <p>Sometimes, my fetch can be a bit slow (>3-4 secs) and during that instance(when a fetch is currently happening), if my custom tableview cell is clicked (on the visible rows) then the app crashes at the following line. (I followed the example <a href="http://www.roostersoftstudios.com/2011/04/14/iphone-uitableview-with-animated-expanding-cells/" rel="nofollow">here</a> to expand/collapse my cell and show more content)
  Obviously the tableview:reloadRowsAtIndexPaths is called as and when network fetch is done and making changes to tableview data..so how can i fix this issue ?</p>
  
  <pre><code>-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  
      NSLog(@"ROW SELECTED..%ld",indexPath.row);
      if (self.selectedIndex ==indexPath.row)
      {
          self.selectedIndex=-1;
          [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
          return;
      }
  
      if (self.selectedIndex!=-1){
          NSIndexPath *prevPath = [NSIndexPath indexPathForRow:self.selectedIndex inSection:0];
          [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:prevPath] withRowAnimation:UITableViewRowAnimationFade];
      }
  
      self.selectedIndex=(int)indexPath.row;
  
      //[self.tableView beginUpdates];
  
     //app crashes at this line !! 
      [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
      //[self.tableView endUpdates];
  }
  </code></pre>
  
  <p>The exception i am getting is </p>
  
  <blockquote>
    <p>*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0.  The number of rows contained in an existing section after the update (10) must be equal to the number of rows contained in that section before the update (11), plus or minus the number of rows inserted or deleted from that section (1 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'</p>
  </blockquote>