No method declared with Objective-C selector

xcode9.1,swift4.0

When I tried swift for the first time, when adding a response event to the button, I used the selector to repeatedly report an error

yourBtn.addTarget(self, action:"clickYourBtn", for: UIControlEvents.touchUpInside) , the error is as the title

yourBtn.addTarget(self, action:Selector("clickYourBtn"), for: UIControlEvents.touchUpInside) 


yourBtn.addTarget(self, action:#selector(clickYourBtn), for: UIControlEvents.touchUpInside) 

The third method can also be used directly in 3.2, but an error will be reported in 4.0, and @objc needs to be added before the method


About selector recommend this article https://www.jianshu.com/p/f3f2c663115d

I have seen that @objc cannot be overused (this article https://www.jianshu.com/p/b50a8ed6a00b)

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326585735&siteId=291194637