Creating target/action pairs in code
<p>I have a custom UITableViewCell that I want to have an action for when a UISegmentedControl (in the tableviewcell) is pressed.  So I created the code in the cellForRowAtIndexPath method like this:</p>

<pre><code>static NSString *SortByCellIdentifier = @"SortByCellIdentifier";
        SortByTableViewCell *cell = (SortByTableViewCell *)[tableView dequeueReusableCellWithIdentifier:SortByCellIdentifier];
        [cell.SortBySegmentedControl addTarget:self action:@selector(SortBySegmentedControlPressed:) forControlEvents:UIControlEventValueChanged];
</code></pre>

<p>I don't ever remember doing anything in the .xib of that cell, but when I click on the File'sOwner (which is of type SortByTableViewCell), I get this picture:</p>

<p><img src="http://i.stack.imgur.com/wZsky.png" alt="enter image description here"></p>

<p>After running it, it works.  By adding the line: [cell.SortBySegmentedControl addTarget:self action:@selector(SortBySegmentedControlPressed:) forControlEvents:UIControlEventValueChanged];</p>

<p>does that create the action for me in IB as seen in the screenshot?  The reason I ask is because I do that with some other cells as well, and the methods never get called.  And when I check the .xib of those UITableViewCells, there is no action wired up like in the screenshot.  So I'm wondering if maybe I did do something in IB and just don't remember it or something.  Thanks.</p>
