I'm trying to create a default implementation of an MKMapViewDelegate by using the conditional extension as follows:
extension MKMapViewDelegate where Self: NSObject {
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
...
}
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
...
}
}
However when I compile the code i get the warning
Non-'@objc' method 'mapView(_:viewFor:)' does not satisfy optional requirement of '@objc' protocol 'MKMapViewDelegate'
I expected the conformance on 'Self' to NSObject would mean that the warning would not occur. On top of the warning the delegate methods are not called even though the delegate instance is a UIViewController and hence conforms to NSObject.
Am I misunderstanding how 'where' works in extensions?