xcode9.1,swift4.0
初试swift,在给按钮添加响应事件时,用selector反复报错
yourBtn.addTarget(self, action:"clickYourBtn", for: UIControlEvents.touchUpInside) ,报错如标题
yourBtn.addTarget(self, action:Selector("clickYourBtn"), for: UIControlEvents.touchUpInside)
yourBtn.addTarget(self, action:#selector(clickYourBtn), for: UIControlEvents.touchUpInside)
第三种方法在3.2还可以直接使用,4.0就会报错,需要方法前加@objc
关于selector推荐这篇文章https://www.jianshu.com/p/f3f2c663115d
有看到说不能过度使用@objc(这篇文章https://www.jianshu.com/p/b50a8ed6a00b)