Argument of '#selector' does not refer to an initializer or method

孤街浪徒 提交于 2019-12-01 12:11:22

You can't have the action parameter specify an arbitrary expression. It needs to invoke a specific selector - a class and function in that class.

You will need to create a function in your class that invokes the delegate method:

class FormulaInfoViewController: UIViewController, Dismissable {

    weak var dismissalDelegate: DismissalDelegate?
    override func viewDidLoad() {
        super.viewDidLoad()

      navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Done", style: .Plain, target: self, action: #selector(FormulaInfoViewController.selectionDidFinish)
    }  

    @objc func selectionDidFinish() {
        self.dismissalDelegate?.selectionDidFinish(self)
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!