提问者:小点点

当使用#selector(Method)时,方法在自动完成中直击,当使用#selector(self.Method)时,则不直击


我有个办法:

@objc func didPressBack(_ sender: UIButton){
   navigationController?.popViewController(animated: true)
}

当我使用#selector(self.didpressback)指定selector时,auto complete正常显示建议。

然而,在这两种情况下,写了名字后,它没有给我任何错误或罢工通过。 而且工作得非常好。 但是我不知道为什么汽车厂给罢工的建议?


共1个答案

匿名用户

我想,如果没有self,Xcode会认为您正在重写具有公共访问权限的子类中的受保护方法didpressback,并对其进行攻击。 Xcode可以警告我们,因为我们不想使用具有puclic访问的infernally类方法