Avatar ·

Why is implicit @objc deprecated in Swift 4 and how to fix it?

Hi everyone! I recently updated my project from Swift 3 to Swift 4 (using Xcode 9 beta) and encountered a bunch of warnings. The compiler says something like: "The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please minimize deprecated @objc inference..." Previously, I wrote code in Swift 3, and my selectors for buttons, target-action, as well as methods called from Objective-C worked fine. For example, this simple code worked without issues: ```swift class MyViewController: UIViewController { @IBOutlet weak var myButton: UIButton! override func viewDidLoad() { super.viewDidLoad() myButton.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside) } func buttonTapped() { print("Button tapped") } } ```