<div dir="ltr">protocol Foo: class {<div> func bar()<br><div><div>}</div><div><br></div><div>extension Foo {</div><div> func bar() {</div><div> print("bar")</div><div> }</div><div>}</div><div><br></div><div>class Baz: Foo {</div></div></div><div> init() {</div><div> let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(bar))</div><div> }</div><div><div>}</div><div><br></div><div>the #selector tells me: "Argument of '#selector' refers to instance method 'bar()' that is not exposed to Objective-C" and asks me to add @objc to the method definition. </div><div><br></div><div>Adding @objc to the method tells me: "@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes"</div><div><br></div><div>Adding @objc to the protocol doesn't fix it, just introduces new issues.</div><div><br></div><div>"dynamic" cannot be applied to a protocol, so cannot be used alternatively. </div><div><br></div><div>Is there a way to get around this? If a method is called by a gesture recognizer, is there no way to have a default protocol implementation? I'd like to use default implementations if possible to make my code more DRY.</div><div><br></div><div>Is there a roadmap/plan for swift-native selector dispatch?</div><div><br></div><div>Thanks. I look forward to the inevitable reply revealing the dumb thing I missed. :)</div><div><div><br></div>-- <br><div class="gmail_signature">Nate Birkholz</div>
</div></div></div>