title: Map view annotations with different pin colors
body: <p>I have an array with over 200 objects and I am trying to perform a loop through each of them.</p>
  
  <p>Each object will have a yes/no field and I want to display a different coloured marker dependent on that yes / no value.  </p>
  
  <p>From what I can see is happening my loop is going through each object first and then all the annotation is added at the end for each object .  </p>
  
  <p>Since I perform a check within my loop through the array on the yes no value when all the annotation is added to my map, it will use the yes/no value from the last object in the array when it goes to plot for all.  </p>
  
  <p>How can I have it so that the marker will be different dependent on the yes/no value for each individual element?</p>
  
  <p>My code is</p>
  
  <pre><code>for (i = 0; i &lt; [appDelegate.itemArray count]; i++) {
          item_details *tempObj = [appDelegate.itemArray objectAtIndex:i];
          location.latitude = [tempObj.lat floatValue];
          location.longitude = [tempObj.lon floatValue];
          current_yesno = tempObj.yesno;
          MapViewAnnotation *newAnnotation = [[MapViewAnnotation alloc]initWithTitle:tempObj.name andCoordinate:location];
          [self.mapView addAnnotation:newAnnotation];
          [newAnnotation release];            
              } 
  </code></pre>
  
  <p>with my annotation code as follows</p>
  
  <pre><code>- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id &lt;MKAnnotation&gt;) annotation{
  
      MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
  
  if(current_yesno == YES){
      annView.pinColor = MKPinAnnotationColorGreen;
  }
  else
  {
      annView.pinColor = MKPinAnnotationColorRed;
  }
      annView.animatesDrop=NO;
      annView.canShowCallout = YES;
      annView.calloutOffset = CGPointMake(-5, 5);
      return annView;
  
  }
  </code></pre>
  
  <p>and <code>current_yesno</code> is declared in my .h file.</p>