title: uiTableViewCell Add row with and image and remove row with second tap
body: <p>I've been trying to figuered this out for hours. I'm just plain old stuck here. What im trying to accomplish is basically inserting a row directly below the row just tapped in the tableview in addition i would like to add and image to the row and and make the image clickable to respond to its click event.</p>
  
  <p>So here is my code.
    I implemented (i belive) the nessesary methods  to handle all the actions for the uitableview. 
  when the user taps the cell i handle that action by executing the following code.</p>
  
  <pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  {
  
      if (debug==1) {
          NSLog(@"running  line 225%@ '%@'", self.class, NSStringFromSelector(_cmd));
      }
  
  
  
      Locations *location = nil;
      Locations *tempObject = [[Locations alloc]init];
  
  
  
  
     //test to see if we are looking for the search box or if we are essentially looking from the main view controller.
      if (self.searchDisplayController.active) {
              location= [self.searchResults objectAtIndex:indexPath.row];
              NSLog(@"location : %@" ,location.locationName);
  
  
      } else {
              location = [self.locations objectAtIndex:indexPath.row];
              NSLog(@"location : %@" ,location.locationName);
          //set the new indexpath to 1 more then before so that we can essetially add a row right below the actual tapped item.
          NSIndexPath *newPath = [NSIndexPath indexPathForRow:indexPath.row + 1 inSection:indexPath.section];
          indexPath = newPath;
  
  
          [self.locations insertObject:tempObject atIndex:indexPath.row ];
  
  
          [tableView insertRowsAtIndexPaths:@[indexPath]  withRowAnimation:UITableViewRowAnimationBottom];
  
          self.visibleCell =YES; //set this boolean variable so that we can add a specific row  image to this var
         // self.locations[0].isItVisible = YES;
  
      }//ends the else statement.
  
  
      [tableView deselectRowAtIndexPath:indexPath animated:YES];
  
  
  
  }
  </code></pre>
  
  <p>the above code inserts an empty cell into my tableview.
  however how can i set the cell so that its custom and not the same as the others. In other words my initial cells data-source are basically bound to an nsobject and a string property location-name. However when i go try to update the table cells in the above method i obviously cannot add an image into a string so I'm running in to a error. 
   so i tried to instead make the update on the </p>
  
  <pre><code> (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  </code></pre>
  
  <p>by basically checking if a variable is set to true or false but that turned out to be buggy because even when i scroll this method gets called.</p>
  
  <p>How should i go about doing this. I think i have to do it all in the didselectrowindexaspath method. But i cant figured out how to change the newly inserted cell to contain an image only. 
  Any help would be appreciated.</p>
  
  <p><strong>EDIT</strong>
  here is what im doing to try to add the image under the <code>cellforrowindexpath</code> method.</p>
  
  <pre><code>if(self.visibleCell==YES){
          UIImage *clkImg = [UIImage imageNamed:@"alarm_clock.png"];
  
          cell.imageView.image = clkImg;
  
      }
  </code></pre>
  
  <p>Im a noob so im not sure im doing this correctly.</p>
  
  <p><strong>EDIT</strong>
  this is the full <code>cellforatindexpath</code></p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      if (debug==1) {
          NSLog(@"running line 159 %@ '%@'", self.class, NSStringFromSelector(_cmd));
      }
     // NSLog(@"cell for row at index path just got called");
  
      //JAMcustomCell *myCell = [[JAMcustomCell alloc]init];
  
      static NSString *CellIdentifier = @"ListPrototypeCell";
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  
  
      if (cell == nil) {
          cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
      }
  
  
      Locations * locations = [[Locations alloc]init];
      //tableView.backgroundColor = [UIColor blackColor];
  
      // NSLog(@"this is visible '%hhd'", locations.isItVisible);
      if(self.visibleCell==YES){
          UIImage *clkImg = [UIImage imageNamed:@"alarm_clock.png"];
  
          cell.imageView.image = clkImg;
  
      }
  
  
  
  
      if (tableView == self.searchDisplayController.searchResultsTableView)
      {
          locations  = [self.searchResults objectAtIndex:indexPath.row];
      }
  
      else{
  
          locations = [self.locations objectAtIndex:indexPath.row];
  
      }
  
  
          cell.textLabel.text = locations.locationName;
          cell.textLabel.textColor = [UIColor whiteColor];
      //cell.backgroundColor =[UIColor blackColor];
    //  cell.backgroundColor =[UIColor colorWithPatternImage:[UIImage imageNamed:@"Graytbl.fw.png"]];
  
      cell.backgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"blueTbl.fw.png"]];
      cell.selectedBackgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"blueTbl.fw.png"]];
     // UIFont *myFont = [ UIFont fontWithName: @"Oswald" size: 25.0 ];
    //  cell.textLabel.font  = myFont;
  
  
      cell.textLabel.font= self.MyFont;//[UIFont fontWithName:@"Oswald-Regular.ttf" size:15];
  
      return cell;
  }
  </code></pre>