title: UITableView Add button on new cell
body: <p>Im trying to add a button into a new cell in a tableview, for example, I need a button under cell '1' if dim is not 0.</p>
  
  <p>However I'm unable to do it. Please enlighten me. </p>
  
  <pre><code>    - (void)viewDidLoad
      {
          [super viewDidLoad];
          _displaynum = [NSArray arrayWithObjects:@"1",@"2",@"3", nil];
          _displayID = [NSArray arrayWithObjects:@"ID = 1",@"ID = 2",@"ID = 3", nil];
      }
  
      - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  
          return [_displaynum count];
  
      }
  
      - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  
          static NSString *lightIdentifier = @"lightIdentifier";
          UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:lightIdentifier];
  
  
          if (cell == nil){
              cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:lightIdentifier];
          }
          UISwitch *switchLights = [[UISwitch alloc] initWithFrame:CGRectMake(1.0, 1.0, 20.0, 20.0)];
          cell.textLabel.text = [_displayLights objectAtIndex:indexPath.row];
          cell.detailTextLabel.text =[_displayLightsID objectAtIndex:indexPath.row];
          cell.accessoryView = switchLights;
          switchLights.on = NO;
          int dim = 1;
          if ((dim =! 0)) {
              NSArray *insertIndexPaths = [NSArray arrayWithObjects:
                                   [NSIndexPath indexPathForRow:1 inSection:0],
                                   nil];
              NSArray *deleteIndexPaths = [NSArray arrayWithObjects:
                                   [NSIndexPath indexPathForRow:2 inSection:0],nil];
  
              [tableView beginUpdates];
              [tableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationRight];
              [tableView deleteRowsAtIndexPaths:deleteIndexPaths withRowAnimation:UITableViewRowAnimationFade];
              [tableView endUpdates];
          }
  
          return cell;
       }
  
  
  
      }
  </code></pre>