title: How do I use a UISegmentedControl to control UITableView cells?
body: <p>I've successfully set up a Tab Bar controller with. Table View in the first view and a simple UIView in the second tab. The UIView has it's own class. I've added a segmented control to the latter and ultimately I want to change the images used in the table view cells depending on which segment is selected.</p>
  
  <p>The cell images are part of an array and have been set up using a custom cell.</p>
  
  <p>I've set up the segmented control in the UIView class adding @property an @syntesize but I can't for the life of me figure out how to change the cell images from the UIView class.</p>
  
  <p>Thanks in advance!</p>
  
  <p>The segment control in my UIView.h is defined like so</p>
  
  <p>@property (weak, nonatomic) IBOutlet UISegmentedControl *selectedSegment</p>
  
  <p>I've not yet included an IBAction as I'm not 100% where it would need to go or how it would be written.</p>
  
  <p>In my table view my cell images are currently defined like so in cellForRowAtIndexPath</p>
  
  <pre><code>cell.itemImageView.image = [UIImage imageNamed:[icons objectAtIndex:indexPath.row]];
  </code></pre>
  
  <p>My thoughts were to put a switch statement within the cell method with each case pointing to a different icon set so</p>
  
  <pre><code>switch (something)
  {
      case 0:
      cell.itemImageView.image = [UIImage imageNamed:[iconSetOne objectAtIndex:indexPath.row]];
      break;
  
      case 1:
      cell.itemImageView.image = [UIImage imageNamed:[iconSetTwo objectAtIndex:indexPath.row]];
      break;
  
      default
      break;
  }
  </code></pre>
  
  <p>But I'm pretty sure that's the wrong way of doing it and the "something" bit is what I'm stuck on.</p>