1

enter image description here

I have updated my code to Swift 3 and now getting the error above. I think there is something wrong with the way selector is called. Anyone please help me, What is wrong.

Adnan Asghar
  • 341
  • 1
  • 3
  • 13
  • Found that link where it is all explained. [Using Swift with Cocoa and Objective-C Swift 3](https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithObjective-CAPIs.html) – Adnan Asghar Sep 17 '16 at 09:46
  • 3
    Possible duplicate of [@selector() in Swift?](http://stackoverflow.com/questions/24007650/selector-in-swift) – Eric Aya Sep 17 '16 at 09:50

3 Answers3

12

Just change your selector syntax with swift 3 selector syntax like this.

 #selector(self.hideKeyboard)
Nirav D
  • 71,513
  • 12
  • 161
  • 183
5

The syntax for Selector has been changed in Swift 3. You don't need to add round brackets after selector name if there is no parameter in the selector.

let tapGesture = UITapGestureRecognizer(target: self, action: #selector(hideKeyboard))
self.view.addGestureRecognizer(tapGesture)
Rohit Arora
  • 169
  • 1
  • 5
0

For anyone looking for a solution can try this.

let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:)))
view.addGestureRecognizer(tap)

// function which is triggered when handleTap is called
 func handleTap(_ sender: UITapGestureRecognizer) {
     print("Hello World")
  }

I know it's loo late to answer, but it can help others.

Sandip Singh
  • 386
  • 5
  • 16