2

This is my code..

class LoginVC: UIViewController, UITextFieldDelegate, , Alertable {

override func viewDidLoad() {
    super.viewDidLoad()

    let tap = UITapGestureRecognizer(target: self, action: #selector(handleScreenTap(sender:)))
    self.view.addGestureRecognizer(tap)
}

And this is the error:

Argument of '#selector' refers to instance method 'handleScreenTap(sender:)' that is not exposed to Objective-C

I tried adding @objc to override func viewDidLoad():

@objc override func viewDidLoad() {

But the same error continues.

How can I fix this?

Rosenberg
  • 2,424
  • 5
  • 33
  • 56

1 Answers1

1

Add @objc to the function in the selector

like this:

@objc func handleScreenTap(sender:Any) {
}
zombie
  • 5,069
  • 3
  • 25
  • 54