I've made a custom MKAnnotation class, MapLocation. I'm having no trouble setting or getting properties, except in this method to create an MKAnnotationView. I need to do it here, since it's supposed to look up a location type from the annotation's index and select one of a family of custom annotation images for the annotationView.
After numerous attempts at setting up custom getters and setters in MapLocation.h and .m, I boiled it down to where I can't even copy the (obligatory) getter, title, rename it to title2, and try to get its return value. This is my code:
-(MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation {
static NSString *placemarkIdentifier=@"Map Location Identifier";
NSString *str1=annotation.title;
NSString *str2=annotation.title2;
if([annotation isKindOfClass:[MapLocation class]]) {
MKAnnotationView *annotationView=(MKAnnotationView *)[theMapView dequeueReusableAnnotationViewWithIdentifier:placemarkIdentifier];
if (annotationView==nil) {
annotationView=[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:placemarkIdentifier];
}
else
annotationView.annotation=annotation;
return annotationView;
}
return nil;
}
On the 4th line, title is returned correctly, but the 5th line's call to the copied method yields the error message in the topic.
I did look in the XCode docs, but I'm probably just not getting how to declare it so this method sees it. Strange that it sees the title getter, but not the title2 copy.