title: How to add a target action to a UITableViewCell
body: <p>I've added a button to a specific UITableViewCell. When I select the button, I get a crash:</p>
  
  <p><code>ButtonTapped
  libc++abi.dylib: terminating with uncaught exception of type NSException</code></p>
  
  <p>At the beginning of <code>cellForRowAt</code>, I'm defining the button:</p>
  
  <pre><code>let myButton = UIButton(type: .custom)
  myButton.frame = CGRect(x: 0, y: 0, width: 20, height: 20)
  myButton.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)
  myButton.tintColor = UIColor.yellow()
  </code></pre>
  
  <p>For the indexpath.row I attach the button like this:</p>
  
  <p><code>cell.accessoryView = myButton as UIView</code></p>
  
  <p>And the action <code>buttonTapped</code> tries to load a different ViewController.</p>
  
  <p>I get confirmation that the button action worked (the routine was called).
  The routine is as follows:</p>
  
  <pre><code>func buttonTapped() {
      print("ButtonTapped")
  
      let myPickerController = self.storyboard?.instantiateViewController(withIdentifier: "picker") as? MyPickerController
      print("1")
      self.present(myPickerController!, animated: true)
      print("2")
  }
  </code></pre>
  
  <p>As you can see from the log, I do see that the routine was called, but I do not see the print values 1 or 2 before the crash. Anyone see what I'm doing wrong? </p>