Reputation: 8708
I'm getting the following warning when adding overlays to my map view:
Sending 'MKOverlayView *const __strong' to parameter of incompatible type 'id<MKOverlay>'
The code works great, and the overlays are drawn as they should, but I would love to get rid of the warning. The code that's causing it:
for(MKOverlayView *overlay in [mapView overlays]) {
[mapView removeOverlay:overlay];
}
(Obviously, the line inside the for loop is what's raising this error) Google doesn't have a single result for that error. only similar with MKAnnotationView for example. The solutions there (for example):
for(id<MKOverlay> *overlay in [mapView overlays]) {
[mapView removeOverlay:overlay];
}
raises an error.
Any ideas? Thanks!
Upvotes: 4
Views: 896
Reputation:
The overlays
property returns an array of the overlay model objects (the objects that conform to the MKOverlay
protocol) and not the overlay views.
So change the for-loop to:
for(id<MKOverlay> overlay in [mapView overlays]) {
Note there is no asterisk in the id<MKOverlay> overlay
part.
Upvotes: 4