title: UITableView action row
body: <p>On the WWDC 11 video 'session 125 - UITableCiew Changes, Tips, Tricks' at 24:30+ Mr Luke Hiesterman is giving a demo which adds a cell to the table view when a cell is selected.</p>
  
  <p><img src="https://i.imgur.com/PAG1j.png" alt="Screenshot from the video"></p>
  
  <p>I want to add that functionality to my IOS application, but I can't figure out how to make it.</p>
  
  <p>Some code is not shown in the demo-video. And there is no downloadable source of the demo.</p>
  
  <p>Can anyone help me out?</p>
  
  <p>EDIT:</p>
  
  <p>I can add a new row below the selected row but it is an other custom cell.</p>
  
  <p>(I have a list of contracts which you can accept)</p>
  
  <pre><code>- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      return ((indexPath.row &gt;= [_contracts count]) ? 40 : 60);
  }
  
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  {
      return [_contracts count] + ((_addedRow) ? 1 : 0);
  }
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      NSString *reuseID = @"contract_cell";
  
      ContractTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseID];
  
      if(!cell)
      {
          // Load the top-level objects from the custom cell XIB.
          NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ContractTableViewCell" owner:self options:nil];
          // Grab a pointer to the first object (presumably the custom cell, as that's all the XIB should contain).
          cell = [topLevelObjects objectAtIndex:0];
          [cell setBackgroundView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"contract_cell.png"]]];
      }
  
      NSLog(@"row?: %d", indexPath.row);
      //I thought this would work... not.
      if((indexPath.row &gt;= [_contracts count]))
      {
          [cell.label setText:@"new"];
      }
      else
      {
          Contract *contract = [_contracts objectAtIndex:indexPath.row];
  
          [cell.label setText:@"test"];
      }
  
      return cell;
  }
  
  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  {
      if(!_addedRow)
      {
          _addedRow = YES;
  
          [tableView deselectRowAtIndexPath:indexPath animated:NO];
  
          [_tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:indexPath.row+1 inSection:indexPath.section]] withRowAnimation:UITableViewRowAnimationAutomatic];
      }
  }
  
  - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
  {
      return [NSIndexPath indexPathForRow:indexPath.row+1 inSection:indexPath.section];
  }
  </code></pre>
  
  <p>For example I press the first row. A row is added below the first one. But now the cellForRowAtIndexPath.. is called for row 2 (needs to be the new custom)</p>
  
  <p>how can I check if it is a new one?</p>