title: iOS: 'NSInternalInconsistencyException', reason: 'attempt to delete row 1 from section 4, but there are only 3 sections before the update'
body: <p>I have created a drop down table view cell, but when inserting and deleting a row into section app crashes with following error,</p>
  
  <pre><code> *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to delete row 1 from section 4, but there are only 3 sections before the update'
  </code></pre>
  
  <p>I am reloading data of tableview with two different arrays on button click.</p>
  
  <pre><code>- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  {
      if (tagforTable==1)
          return [updateDataArray count];
      else
          return [offersDataArray count];
  }
  - (void)didSelectCellRowFirstDo:(BOOL)firstDoInsert nextDo:(BOOL)nextDoInsert
  {
      [self.notificationTable beginUpdates];
  
      int section;
      self.isOpen = firstDoInsert;
  
      Cell1 *cell = (Cell1 *)[self.notificationTable cellForRowAtIndexPath:self.selectIndex];
      [cell changeArrowWithUp:firstDoInsert];
  
  
      section = self.selectIndex.section;
  
      dbObj=[[DatabaseHelper alloc]init];
      if (tagforTable==1)
      {
          [dbObj updateTagUpdate:section];
      }
      else if(tagforTable==2)
      {
          [dbObj updateTagOffers:section];
      }
      [upCount removeAllObjects];
      [ofCount removeAllObjects];
      upCount=[dbObj SelectTagForUpdate];
      ofCount=[dbObj SelectTagForOffers];
      notificationBtn.badgeValue = [NSString stringWithFormat:@"%d",[upCount count]+[ofCount count]];
      notificationBtn.badgeBGColor = [UIColor redColor];
  
  
      NSMutableArray* rowToInsert = [[NSMutableArray alloc] init];
  
      NSIndexPath* indexPathToInsert = [NSIndexPath indexPathForRow:1 inSection:section];
      [rowToInsert addObject:indexPathToInsert];
  
      if (firstDoInsert)
      {   [self.notificationTable insertRowsAtIndexPaths:rowToInsert withRowAnimation:UITableViewRowAnimationTop];
      }
      else
      {
          [self.notificationTable deleteRowsAtIndexPaths:rowToInsert withRowAnimation:UITableViewRowAnimationTop];
      }
  
      [rowToInsert release];
  
      if (nextDoInsert) {
          self.isOpen = YES;
          self.selectIndex = [self.notificationTable indexPathForSelectedRow];
          [self didSelectCellRowFirstDo:YES nextDo:NO];
      }
      if (self.isOpen) [self.notificationTable scrollToNearestSelectedRowAtScrollPosition:UITableViewScrollPositionTop animated:YES];
      [self.notificationTable endUpdates];
  
  }
  </code></pre>
  
  <p>where I am going wrong ? Help !</p>