title: Delete tableView row
body: <p>I have dynamic tableView with custom cells in it, i want to delete some cell if its value is 0, for example.</p>
  
  <p>Here's my <code>tableView:cellForRowAtIndexPath</code> method:</p>
  
  <pre><code>{
      NSString *CellIdentifier;
      UITableViewCell *cell;
  
      if (indexPath.row == 0){
          CellIdentifier = @"adress cell";
          CustomAdressCell *cell = [detailsTableView dequeueReusableCellWithIdentifier:CellIdentifier];
  
         if (cell == nil) {
              NSArray *objects = [[NSBundle mainBundle] loadNibNamed:@"CustomTimeCell" owner:self options:nil];
              cell = [objects lastObject];
          }
          cell.someValue = self.someVal;
  
        return cell;
      }
  
      else if (indexPath.row == 1){
          CellIdentifier = @"phone cell";
          CustomPhoneCell *cell = [detailsTableView dequeueReusableCellWithIdentifier:CellIdentifier];
  
          if (cell == nil) {
              NSArray *objects = [[NSBundle mainBundle] loadNibNamed:@"CustomPhoneCell" owner:self options:nil];
              cell = [objects lastObject];
          }
  
          indexPathTest = indexPath;//index path for delete
          cell.someValue = self.someVal2;
  
          return cell;
      }
  ...
      else return cell;
  }
  </code></pre>
  
  <p>For example: if i have <code>cell.someValue = 0</code> on second row, i need to delete this row. How can i achieve this? Thanks!</p>
  
  <p>EDIT: i'm trying to delete rows after i initialised my tableView in another VC with the following code(custom method):</p>
  
  <pre><code>        [self.detailsTableView beginUpdates];
          [self.detailsTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPathTest]
                           withRowAnimation:UITableViewRowAnimationFade];
          [self.detailsTableView endUpdates];
  </code></pre>
  
  <p>And i'm having error: </p>
  
  <pre><code>Invalid update: invalid number of rows in section 0.  The number of rows contained in an 
  existing section after the update (4) must be equal to the number of rows contained in that  
  section before the update (4), plus or minus the number of rows inserted or deleted from that   
  section (0 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that 
  section (0 moved in, 0 moved out).'
  </code></pre>
  
  <p>Some other questions that didn't helped me:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/18961581/ios-delete-a-tableview-row">iOS delete a tableview row</a></li>
  <li><a href="https://stackoverflow.com/questions/6657919/how-to-remove-a-cell-from-table">How to remove a cell from table</a></li>
  </ul>