Finding Custom AnnotationViews with MKMapView
If you’ve subclassed MKAnnotationViews and created your own custom MKAnnotation then you’ll find yourself writing a lot of code like this:
This is quite undesireable, and you know what this means! We can write a nice extension method for it using generics.
We created an extension method that helps wrangle the type of the class on the way in and out.
So the way we use this is quite simple:
Remember because of the nature of
MKMapView, which operates quite closely to
annotationView can be
For example, you may have an annotation centered in Dubai but your map is focused primarily around San Franscisco. Just because you’ve alled
Doesn’t mean that the mapView will render anything at all.
So you will have to check if the annotationView is available at all for mutation.