Swift: Members of protocol extensions cannot be declared @objc

Originator:joe
Number:rdar://22611665 Date Originated:9/8/15
Status:Duplicate of 21552427 Resolved:
Product:Developer Tools Product Version:Xcode 7
Classification: Reproducible:Yes
 
Summary:
So when I try to connect a UIGestureRecognizer's target-action to the handleGesture function I get an unrecognized selector exception. If I then add @objc to the function to try and use dynamic dispatch I get a compiler error: “Members of protocol extensions cannot be declared @objc”

I would think this should be supported as the work around I posted on the forums seems absolutely unnecessary.

Developer Forums Post: https://forums.developer.apple.com/thread/16773

Relevant code:
 
protocol SomeProtocol: class {  
     func handleGesture(gesture: UILongPressGestureRecognizer)  
  
}  
extension SomeProtocol where Self: UITableViewController {  
    func handleGesture(gesture: UILongPressGestureRecognizer) { . . . }  
}  
 
class MasterViewController: UITableViewController, SomeProtocol {  
var gesture: UILongPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: "handleGesture:")  

override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        tableView.addGestureRecognizer(gesture)
}
}

Expected Results:
Gesture should call the default implementation of handleGesture defined by the protocol extension.

Actual Results:
unrecognized selector exception

Notes:
Relevant post in the developer forums: https://forums.developer.apple.com/thread/16773

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!