如何删除所有注释引脚然后添加一个新注释引脚

Gre*_*reg 1 annotations mkmapview ios

好奇,如果有人可以帮助一件事:

我只想告诉Xcode,如果地图上同时存在"addAnnotation"和"newAnnotation"引脚,则删除初始的"newAnnotation"引脚.

我的非工作代码如下:

if ([self.mapView addAnnotation:addAnnotation] & [self.mapView addAnnotation:newAnnotation] return)
{
    [self.mapView removeAnnotation:newAnnotation];
}
Run Code Online (Sandbox Code Playgroud)

谢谢!

Gre*_*reg 6

谢谢你的反馈,但我解决了这个问题:

NSArray *existingpoints = mapView.annotations;

if ([existingpoints count])
    [mapView removeAnnotations:existingpoints];
Run Code Online (Sandbox Code Playgroud)