title: Implementing accessoryButtonTappedForRowWithIndexPath: in Swift 2
body: <p>I'm attempting to implement <code>accessoryButtonTappedForRowWithIndexPath:</code> in Swift 2 on a <code>UITableViewController</code>.</p>
  
  <p>As I explain below, I think I'm missing something in when I create the <code>disclosureIndicator</code>, but I don't know what. It gets drawn from code, but my target action doesn't get called. UGH!</p>
  
  <p>To do this programmatically, my understanding is I need to add the detailDisclosure indicator in <code>cellForRowAtIndexPath</code> before my <code>cell</code> is returned. I'm doing that as follows:</p>
  
  <pre><code>// Create disclosure indicator button in the cell
  let disclosureIndicatorButton = UIButton(type: UIButtonType.DetailDisclosure)
  disclosureIndicatorButton.addTarget(self, action: "disclosureIndicatorPressed:event:", forControlEvents: UIControlEvents.TouchUpInside)
  customCell.accessoryType = .DisclosureIndicator
  </code></pre>
  
  <p>In my code, the detailDisclosure chevron gets drawn, but the target action method I assigned to it doesn't get called.</p>
  
  <p>Then I need to create a handler for the button when it's pressed:</p>
  
  <pre><code>func disclosureIndicatorPressed(sender: UIButton, event: UIControlEvents) {
      print("disclosure button pressed")
      // convert touches to CGPoint, then determine indexPath
      // if indexPath != nil, then call accessoryButtonTappedForRowWithIndexPath
  }
  </code></pre>
  
  <p>Finally <code>accessoryButtonTappedForRowWithIndexPath</code> contains code to perform the segue, which I can do. What am I missing?</p>
  
  <p><a href="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewDelegate_Protocol/#//apple_ref/occ/intfm/UITableViewDelegate/tableView:accessoryButtonTappedForRowWithIndexPath" rel="noreferrer">https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewDelegate_Protocol/#//apple_ref/occ/intfm/UITableViewDelegate/tableView:accessoryButtonTappedForRowWithIndexPath</a>:</p>