0

Is there a way to remove the last added Annotation?

j0k
  • 22,303
  • 28
  • 77
  • 86
MotoxX
  • 877
  • 1
  • 7
  • 13
  • See http://stackoverflow.com/questions/13017305/how-to-reorder-mkmapview-annotations-array and http://stackoverflow.com/questions/9539802/mkmapview-annotations-changing-losing-order?lq=1 for an explanation of why using the map view's annotations array won't always work. –  Nov 08 '12 at 13:03

1 Answers1

4

[self.mapView removeAnnotation:self.mapView.annotations.lastObject];

fulvio
  • 25,423
  • 20
  • 127
  • 202
HackyStack
  • 4,609
  • 3
  • 21
  • 28
  • 1
    If this solves your problem, be sure to mark as correct please. – HackyStack Nov 07 '12 at 21:45
  • 2
    unfortunatly this doesn't solve the problem, because the last object is the Userlocation. So I thought I remove the second last object but I found out, that this is not always the last added Annotation (no idea why). But I solved my problem now by just adding the annotation to an array and taking this for deleting the last annotation. But nevertheless thanks for your help! – MotoxX Nov 08 '12 at 07:40