I have a MapViewController for presenting annotations on map. It contains an object of type MapPresentable.
protocol MapPresentable {
associatedtype AnnotationElement: MKAnnotation
var annotations: [AnnotationElement] { get }
}
class MapViewController<M: MapPresentable>: UIViewController {
var mapPresentable: M!
}
MapViewController can also present route on map in case mapPresentable
conforms to RoutePresentable protocol.
protocol RoutePresentable: MapPresentable {
var getRouteLocations: [CLLocation] { get }
}
But when checking made inside MapViewController
if let routePresentable = mapPresentable as? RoutePresentable {
showRoute(routePresentable.getRouteLocations)
}
I got this Error:
Protocol 'RoutePresentable' can only be used as a generic constraint because it has Self or associated type requirements