I have some pins that the user can add. In the callout there is a button. When the user presses the button, I want a new pin to drop in that location, and I want to get rid of the pin that the user pressed (different types of pins).
Basically the first pin is draggable, and when the user has found a proper location they will "lock" it. (the locked pin acts differently in a few ways, which is why I need to replace the old pin)
anyways, this is the method where I do my processing. When I get to the [mapView removeAnnotation:view.annotation]; part all I get is "Program received signal: “EXC_BAD_ACCESS”."
Can anybody help me out here? (The issue is not that the new annotation does not appear, as it does appear. The issue is that the old annotation does not dissapear). EDIT: Fixed code as per suggestion.
- (void) mapView:(MKMapView *)MapView
annotationView:(MKAnnotationView *)view
calloutAccessoryControlTapped:(UIControl *)control {
LockedPotholeAnnotation *annotation = [[[LockedPotholeAnnotation alloc] initWithCoordinate:view.annotation.coordinate addressDictionary:nil]autorelease];
NSString *titleString = [NSString stringWithFormat:@"Pothole at %.4f, %.4f", view.annotation.coordinate.latitude, view.annotation.coordinate.longitude];
annotation.title = titleString;
[mapView addAnnotation:annotation];
//[annotation release];
NSLog(@"Added Pin");
NSLog(@"VA: %@", [view.annotation class]);
[mapView removeAnnotation:view.annotation];
//[mapView removeAnnotations:mapView.annotations];
[mapView setNeedsDisplay];
}