0

Why is it so useful to delete annotations?

[self.mapView removeAnnotations:[self.mapView annotations]];

It doesn't work.do this:

[self.mapView removeAnnotations:self.mapView.annotations];

The system definition:

- (void)removeAnnotations:(NSArray<id<MKAnnotation>> *)annotations;
TW520
  • 86
  • 6
  • Please confirm if your question is about the syntax of the mentioned function? Have you checked this answer already: https://stackoverflow.com/questions/3027392 – Kushal Ashok Apr 09 '18 at 07:48

1 Answers1

0

If the question is really WHY, this is what you can find reading the official documentation :

If the annotation is currently associated with an annotation view, and that view has a reuse identifier, this method removes the annotation view and queues it internally for later reuse. You can retrieve queued annotation views (and associate them with new annotations) using the dequeueReusableAnnotationViewWithIdentifier: method.

Removing an annotation object disassociates it from the map view entirely, preventing it from being displayed on the map. Thus, you would typically call this method only when you want to hide or delete a given annotation.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Thomas Mary
  • 1,535
  • 1
  • 13
  • 24
  • Thank you for your reply. but,It doesn't work.do this: ```self.mapView.annotations``` why??? – TW520 Apr 10 '18 at 06:16