title: Objective C - How to implement custom callback method but enforce specific parameter?
body: <p>In my app I have a custom UITableViewCell subclass that pops up a picker when pressed. from now on I'll refer to this class as <code>PickerCell.</code>
  I'm using several of instances of PickerCell in the same <code>UITableView</code>.</p>
  
  <p>I don't want the cell to respond to the selection of a row in the picker, because it's not a good MVC.
  Instead I want the ViewController to give the cell a callback that will be called upon selection of row.</p>
  
  <p>The most obvious way is to create a protocol like <code>PickerCellDelegate</code> and the view controller will pass himself to each cell.</p>
  
  <p>My problem with this approach is that since I have several PickerCells, my implementation of the protocol in the ViewController will have to distinguish between each cell:</p>
  
  <pre><code>-(void) pickerCell : (PickerCell *) sender 
        didSelectRow : (NSInteger) row 
         inComponent : (NSInteger) component
  {
      if (sender == X)
      // Something
      else if (sender == Y)
      // Something else...
      // etc...
  }
  </code></pre>
  
  <p>And <strong>I hate this coding style...</strong></p>
  
  <p>Instead I would really like a mechanism that allow the ViewController to give it's own callback.</p>
  
  <p>I can allow the PickerCell to accept a "<code>onRowSelectedSelector</code>", but then how do I ensure that this selector is in the format that I want? (Number of parameters is the most important)</p>
  
  <p>Even better, I would like to give the Picker cell a <strong>block</strong> to execute on selection, because I know blocks can be defined with specific parameters. In addition there is no need to pass a "target" object.</p>
  
  <p>So how do I do such a thing?</p>
  
  <p>Thanks!</p>