title: Protocol Extensions with Selectors in Swift
body: <p>I am trying to extend a Protocol in Swift by adding a registerGestureRecognizers function. Here is the complete implementation.</p>
  
  <p>The FilterableView is used by classes that inherit from UIImageView.  </p>
  
  <pre><code>import UIKit
  
  protocol FilterableView : class  {
  
      var name :String { get }
      var view :UIImageView { get } 
  
      func applyFilter(originalImage :UIImage) -&gt; UIImage
  }
  
  extension FilterableView {
  
      func registerGestureRecognizers() {
  
          let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(Self.filterTapped(_:)))
  
      }
  
      func filterTapped(recognizer :UITapGestureRecognizer) {
              print("filter Tapped")
      }
  
  }
  </code></pre>
  
  <p>At this line: </p>
  
  <pre><code> let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(Self.filterTapped(_:)))
  </code></pre>
  
  <p>I get the following message: </p>
  
  <pre><code>Argument of '#selector' refers to a method that is not exposed to Objective-C
  </code></pre>
  
  <p>What am I missing? </p>
  
  <p>I added the @objc keyword but same issues. </p>
  
  <p><a href="https://i.stack.imgur.com/NEDjy.png"><img src="https://i.stack.imgur.com/NEDjy.png" alt="enter image description here"></a></p>
  
  <p>UPDATE 2: </p>
  
  <p>Now, I have problem in my classes that are conforming to the FilterableView protocol. Xcode is complaining that I must implement the filterTapped function in my classes, even though I have provided the implementation in the protocol extension method.</p>