I am attempting to loop through all of a maps annotations and check to see if it's a MKUserLocation annotation. If it's not I want to remove it so I can add some other ones. I am trying to use the code below but it crashes w /the following error: "Terminating app due to uncaught exception 'NSGenericException', reason: '* Collection <__NSArrayM: 0x1645d0> was mutated while being enumerated."
for(id a in [[self mapview] annotations]) {
if([a class] != [MKUserLocation class]) {
[[self mapview] removeAnnotation:a];
}
}
How can I properly loop through all of the annotations and remove them while still ensuring that the userLocation marker isn't removed.