views:

212

answers:

1

Hi everyone, i'm having problems trying to update an annotation location with different coordinates. Is there any way I can change de location property without having to create another annotation? I've tried the code below with no luck. The annotation i'm trying to get is not updating its location. Please help!

CLLocationCoordinate2D location;
location.latitude = -36.560976;
location.longitude = -59.455807; 

for (id annotation in self.mapView.annotations) {

    if ([annotation isKindOfClass:[MyAnnotation class]]) 
    {
            [annotation setCoords:location]; //setCoords is defined in MyAnnotation class
            }
    }

Thank you all!

A: 

You need to remove the annotation and add it again after changing its coordinates, or replace it with a new one. MapKit does not assume annotations might be mutable.

Graham Lee