iPhone: Remove annotation from MKMapView which is in another view
- by Nic Hubbard
I have two views. The first is a MKMapView with some annotations. Clicking a UIButton pushes a second view on the stack. This has a UITableView with a list of annotations which correspond to the map annotations. So, when you click the delete button, how can I call my MKMapView which is in another view, so that I can remove the annotation. My MKMapView is declared in my app delegate, as well as my current class. I am trying to use the following, but it is not working:
RideAppDelegate *appDelegate = (RideAppDelegate *)[[UIApplication sharedApplication] delegate];
Annotation *ano;
CLLocationCoordinate2D anoPoint;
anoPoint.latitude = [[eventToDelete valueForKey:@"latitude"] doubleValue];
anoPoint.longitude = [[eventToDelete valueForKey:@"longitude"] doubleValue];
ano = [[[Annotation alloc] init] autorelease];
ano.coordinate = anoPoint;
[appDelegate.ridesMap removeAnnotation: ano];
[appDelegate release];
I must be trying to access the MKMapView of my other view incorrectly?