title: Argument of '#selector' does not refer to an initializer or method
body: <p>I have a method called <code>selectionDidFinish(controller:)</code> in a delegate to dismiss the viewController the delegate presented. The presented controller, which adopts my <code>Dismissable</code> protocol, has a <code>UIBarButtonItem</code> with an action attached to it that should call the <code>selectionDidFinish(controller:)</code> method but it's giving me the "Argument of '#selector' does not 'refer' to an initializer or method" error.</p>
  
  <p>The error is in this presented <code>UIViewController</code>:</p>
  
  <pre><code>class FormulaInfoViewController: UIViewController, Dismissable {
  
      weak var dismissalDelegate: DismissalDelegate?
      override func viewDidLoad() {
          super.viewDidLoad()
  
      // Xcode doesn't like this selector
      navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Done", style: .Plain, target: self, action: #selector(dismissalDelegate?.selectionDidFinish(self)))
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  }
  </code></pre>
  
  <p>I've confirmed that the <code>dismissalDelegate</code> is getting set properly to <code>FormulasTableViewController</code> so I can't understand why it can't see <code>dismissalDelegate?.selectionDidFinish(self))</code>. </p>
  
  <p>The relevant code of my presenting <code>UIViewController</code> is:</p>
  
  <pre><code>class FormulasTableViewController: UITableViewController, DismissalDelegate {
  
    let formulas: [CalculationFormula] = [
      CalculationFormula.epley,
      CalculationFormula.baechle,
      CalculationFormula.brzychi,
      CalculationFormula.lander,
      CalculationFormula.lombardi,
      CalculationFormula.mayhewEtAl,
      CalculationFormula.oConnerEtAl]
  
    override func viewDidLoad() {
      super.viewDidLoad()
  
      let liftInfoImage = UIImage(named: "info_icon")
      let liftInfoButton = UIBarButtonItem(image: liftInfoImage, style: .Plain, target: self, action: #selector(self.segueToFormulaInfo(_:)))
      self.navigationItem.rightBarButtonItem = liftInfoButton 
    }
  
    func selectionDidFinish(controller: UIViewController) {
      self.dismissViewControllerAnimated(true, completion: nil)
      }
  
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
      let nav = segue.destinationViewController as! UINavigationController
      let vc = nav.topViewController as! Dismissable
      vc.dismissalDelegate = self
      }
  
    func segueToFormulaInfo(sender: UIButton) {
        performSegueWithIdentifier("segueToFormulaInfo", sender: self)
      }
  }
  </code></pre>
  
  <p>I've done all kinds of research on how to use <code>#selector</code> and I thought <a href="https://stackoverflow.com/questions/24007650/selector-in-swift?rq=1">this post</a> had all the answers, but it doesn't.</p>
  
  <p>I've tried this Dismissable protocol with and without exposing it to <code>@objc</code>:</p>
  
  <pre><code>@objc protocol Dismissable: class {
      weak var dismissalDelegate: DismissalDelegate? {
          get set }
      }
  </code></pre>
  
  <p>And I've also tried it with my DismissalDelegate protocol:</p>
  
  <pre><code>@objc protocol DismissalDelegate : class {
      func selectionDidFinish(controller: UIViewController)
  }
  
  extension DismissalDelegate where Self: UIViewController {
      func selectionDidFinish(viewController: UIViewController) {
      self.dismissViewControllerAnimated(true, completion: nil)
      }
  }
  </code></pre>
  
  <p>I can't expose my protocol extension to <code>@objc</code> - is that why this doesn't work? Is my <code>#selector</code> really the problem here? Does it have something to do with my protocols? </p>
  
  <p><strong>EDIT: Final fix</strong></p>
  
  <p>Based on the accepted answer, I added a function to do the dismissal:</p>
  
  <pre><code>func dismiss() {
      dismissalDelegate?.selectionDidFinish(self)
  }
  </code></pre>
  
  <p>and then called the selector like this:</p>
  
  <pre><code>    navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Done", style: .Plain, target: self, action: #selector(dismiss))
  </code></pre>