Argument of '#selector' compiler error

I couldn’t get the provided code sample to work without a compiler error when instantiating the doubleTapRecognizer. The use of “#selector” for the action parameter caused an error with Xcode 9.2:

“Argument of ‘#selector’ refers to instance method ‘tap’ that is not exposed to Objective-C”

I won’t duplicate the code, because it matches the printed one.

The “fix” was to expose the method doubleTap(_:slight_smile: to objective-C.

I’m not certain what this means, but it required adding “@objc” to the function declaration:

 @objc func doubleTap(_ gestureRecognizer: UIGestureRecognizer) {
    print ("Recognized a double tap")
    
    currentLines.removeAll()
    finishedLines.removeAll()
    setNeedsDisplay()
}

This is happening in Swift 4 to improve performance : https://www.hackingwithswift.com/example-code/language/how-to-fix-argument-of-selector-refers-to-instance-method-that-is-not-exposed-to-objective-c

Hope this helps.

Thank you so much. I am but only grasshopper in your shadow.