Argument of '#selector' refers to instance method 'action' that is not exposed to Objective-C

在 Swift 4.0 中会报错:Argument of '#selector' refers to instance method 'action' that is not exposed to Objective-C。解决办法有两种:
1、在该类前加上:

@objcMembers
class ViewController: UIViewController {
}

2、在方法名前加上:

@objc func action() {
        print("add")
}



作者:Desmond_
链接:https://www.jianshu.com/p/65a48d470139
来源:简书

你可能感兴趣的:(概念)