How can I deal with @objc inference deprecation with #selector() in Swift 4?

后端 未结 5 1636
遥遥无期
遥遥无期 2020-11-22 04:59

I\'m trying to convert my project\'s source code from Swift 3 to Swift 4. One warning Xcode is giving me is about my selectors.

For instance, I add a target to a butt

5条回答
  •  不思量自难忘°
    2020-11-22 05:51

    As of, I think Swift 4.2, all you need to do is to assign @IBAction to your method and you can avoid this silly @objc annotation

    ```

    let tap  =  UITapGestureRecognizer(target: self, action: #selector(self.cancel))
    
    
    @IBAction func cancel()
    {
        self.dismiss(animated: true, completion: nil)
    }
    

提交回复
热议问题