title: iOS UITableView Cell Selection
body: <p>I have a UITableView with a custom cell called NewCell and I am trying to show a UIView called 'selectedView' within NewCell upon the click event.</p>
  
  <pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  {
      NewCell *cell = (NewCell*)[tableView cellForRowAtIndexPath:indexPath];
      [cell.selectedView setHidden:NO];
  }
  </code></pre>
  
  <p>EDIT - Adding cell creation code:</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      static NSString *CellIdentifier = @"NewCell";
      NewCell *productCell = (NewCell *)[self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  
      if (productCell == nil) 
      {
          NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"NewCell" owner:nil options:nil];
  
          for (id currentObject in topLevelObjects)
          {
              if([currentObject isKindOfClass:[UITableViewCell class]])
              {
                  productCell = (NewCell *) currentObject;
                  break;
              }
          }
      }
  
      Product *mainProduct = [self.productsArray objectAtIndex:indexPath.row];
  
      float floatPrice = [mainProduct.price floatValue];
      NSString *priceFormat;
      if ((int)floatPrice == floatPrice) priceFormat = @"$%.0f"; else priceFormat = @"$%.2f";
  
      produtCell.productPrice.text = [NSString stringWithFormat:priceFormat, floatPrice];
  
      return productCell;
  }
  </code></pre>
  
  <p>Everything works fine and the table populates, but when I select a cell, it does not show selectedView on the cell that was selected in the table, but rather it shows selectedView in an opposite cell.
  What I mean by this is, if row 0 and 1 are shown on the screen and I select row 1, it will show the selectedView on row 0 and if I select row 0, it will show selectedView on row 1.  </p>
  
  <p>Very strange, I can't seem to tell why it is doing this.</p>
  
  <p>I must be doing something wrong.</p>