I am getting this error
"Nil is incompatible with return type 'MKOverlayRenderer'".
Here is my code:
func mapView(mapView: MKMapView, rendererForOverlay overlay: MKOverlay) -> MKOverlayRenderer {
if overlay is MKCircle {
let circleRenderer = MKCircleRenderer(overlay: overlay)
circleRenderer.lineWidth = 1.0
circleRenderer.strokeColor = UIColor.purpleColor()
circleRenderer.fillColor = UIColor.purpleColor().colorWithAlphaComponent(0.4)
return circleRenderer
}
return nil
}
why is it occurring?
return MKPolylineRenderer() instead of returning nil.
This seems to be answered here:
Swift 2 MKMapViewDelegate rendererForOverlay optionality
You are just not allowed to return nil. Your overlay must have a renderer. Replace "return nil" with an assertion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With