Quote:
Originally Posted by Ovidius
No worries, but I do get some errors which I don't know how to deal with:
Code:
- (MKAnnotationView *)mapView:(MKMapView *)aMapView viewForAnnotation:(id <MKAnnotation>)anAnnotation
{
if ([anAnnotation isKindOfClass:MapAnnotation]) <- expected expression before 'MapAnnotation'
{
MapAnnotation *theAnnotation = [[MapAnnotation alloc] init];
theAnnotation = (MapAnnotation *)anAnnotation; <- 'theAnnotation' undeclared (first use in this function)
if (theAnnotation.identifier == @"StartAnnotation")
{
MKPinAnnotationView *startAnnotationPin = [[MKPinAnnotationView alloc] initWithAnnotation:anAnnotation reuseIdentifier:@"StartPin"];
startAnnotationPin.pinColor = MKPinAnnotationColorGreen;
return startAnnotationPin;
}
return nil;
}
} <-- control reaches end of non-void function
|
OK I got it now, for those who may want the same answer:
Code:
- (MKAnnotationView *)mapView:(MKMapView *)aMapView viewForAnnotation:(id <MKAnnotation>)anAnnotation
{
if ([anAnnotation isKindOfClass:[MapAnnotation class]])
{
MapAnnotation *theAnnotation = (MapAnnotation *)anAnnotation;
if (theAnnotation.identifier == @"StartAnnotation")
{
MKPinAnnotationView *startAnnotationPin = [[MKPinAnnotationView alloc] initWithAnnotation:anAnnotation reuseIdentifier:@"StartPin"];
startAnnotationPin.pinColor = MKPinAnnotationColorGreen;
return startAnnotationPin;
}
}
return nil;
}
I guess I should note I included an NSString named identifier in the class of MapAnnotation...
Duncan, thanks so much for your help, it went a long way. I never did map annotations until now, and the way they are implemented in the framework is extremely weird IMHO, but anyways, thank you. Without your guidance I don't know how else I could have understood the MKAnnotation class.