Swift: Gesture Recognizer unrecognized selector sent to instance

I’m attempting to make a gesture recognizer in XCode, so that I can tap on my MKMapView and preform some actions. However, I am receiving the “unrecognized selector sent to instance” whenever I long-press the map.

Here is my code in viewDidLoad:

  • Private data sharing using CloudKit
  • AdMob interstitial error “Request Error: No ad to show”
  • How do I set BarChart X-Axis and Y-Axis Labels using Swift 3.0
  • iPhone: AVAudioPlayer unsupported file type
  • iOS 7 Background Fetch When the App is Not Running
  • UIView surface custom transformation/animation (like 'a water drop effect')
  • let gestureRecognizer = UILongPressGestureRecognizer(target: self, action: "handleTap:");
    self.mapViewPlace.addGestureRecognizer(gestureRecognizer);
    

    And here is the function later on:

    func handleTap(gestureReconizer: UILongPressGestureRecognizer) {
    
    }
    

    Any ideas?

    Solutions Collect From Internet About “Swift: Gesture Recognizer unrecognized selector sent to instance”

    Please, give Neo credit. You need to change your syntax to this:

    let gestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(handleTap)
    

    Side note: For Swift you do not need semi-colons the end your code lines.