title: UISegmentedControl duplicating in UITableViewCell
body: <p>In my UITableView Controller I have cells which each contain a UILabel and UISegmentedController. There are about 20 cells in total. The user can select the UISegmentedControl to control whether object is contained in an array or not.</p>
  
  <p>My problem is that as the user scrolls the UISegmentedControl is duplicated and appears as though there are multiple selections for UISegmentedControl. I have a feeling that this is because cells are being reused but unfortunately I don't have a very good understanding of reusing cells.</p>
  
  <p>I have been trying to play around with:</p>
  
  <pre><code>if(cell == nil){}
  </code></pre>
  
  <p>but I am not sure what should happen there:</p>
  
  <p>Anyway here is my code:</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
  static NSString *CellIdentifier = @"featuresCell";
  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  NSString *feature = [features objectAtIndex:indexPath.row];
  UILabel *titleLabel = (UILabel *)[cell viewWithTag:9999];
  titleLabel.text = feature;
  
      UISegmentedControl *segmentedControl = [[UISegmentedControl alloc]initWithItems:[NSArray arrayWithObjects:@"Yes", @"No", nil]];
      segmentedControl.frame = CGRectMake(215, 17, 85, 28);
      [segmentedControl addTarget:self action:@selector(valueChanged:) forControlEvents: UIControlEventValueChanged];
      segmentedControl.tag = indexPath.row;
      [cell addSubview:segmentedControl];
  
  if ([selectedFeatures containsObject:feature]) {
      segmentedControl.selectedSegmentIndex = 0;
  }
  else{
      segmentedControl.selectedSegmentIndex = 1;
  }
  
  
  return cell;
  }
  </code></pre>
  
  <p>Your help will be greatly appreciated,</p>
  
  <p>Thanks for your time.</p>