I need to change the color for an MKPointAnnotation
object, but the method I wrote seems to only generate red pins. The method works fine, but when I call the function, passing the parameter of one of the given constant, all pins that appear on the map are red (the default). Any thoughts? Code below.
-(MKAnnotationView*) returnPointView: (CLLocationCoordinate2D) location andTitle: (NSString*) title andColor: (int) color{
/*Method that acts as a point-generating machine. Takes the parameters of the location, the title, and the color of the
pin, and it returns a view that holds the pin with those specified details*/
MKPointAnnotation *resultPin = [[MKPointAnnotation alloc] init];
MKPinAnnotationView *result = [[MKPinAnnotationView alloc] initWithAnnotation:resultPin reuseIdentifier:Nil];
[resultPin setCoordinate:location];
resultPin.title = title;
result.pinColor = color;
return result;
}
//Function that calls above method
for(Party *party in allParties){
if(!party.alreadyAdded){
CLLocationCoordinate2D location = [party getPartylocation];
NSString *partyTitle = [party getPartyName];
MKAnnotationView *partyPin = [self returnPointView:location andTitle:partyTitle andColor:MKPinAnnotationColorGreen];
[self.map addAnnotation:partyPin.annotation];
NSLog(@"Adding Successful!");
party.alreadyAdded = YES;
}
}