title: Custom MKAnnotationView Showing Wrong Image
body: <p>I have an <code>MKMapView</code> where I want to display annotations of contacts' faces.  I looked at Apple's sample app <a href="https://developer.apple.com/library/mac/samplecode/MapCallouts/Introduction/Intro.html" rel="nofollow">MapCallouts</a> and have so far written this:</p>
  
  <p><strong>Annotation.h</strong></p>
  
  <pre><code>@interface Annotation : NSObject &lt;MKAnnotation&gt;
  
  @property (nonatomic, strong) UIImage *image;
  @property (nonatomic, readwrite) CLLocationCoordinate2D coordinate;
  
  + (MKAnnotationView *)createViewAnnotationForMapView:(MKMapView *)mapView annotation:(id &lt;MKAnnotation&gt;)annotation;
  
  @end
  </code></pre>
  
  <p><strong>Annotation.m</strong></p>
  
  <pre><code>#import "CustomAnnotationView.h"
  
  @implementation Annotation
  
  + (MKAnnotationView *)createViewAnnotationForMapView:(MKMapView *)mapView annotation:(id &lt;MKAnnotation&gt;)annotation
  {
      MKAnnotationView *returnedAnnotationView =
      (CustomAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"Annotation"];
      if (returnedAnnotationView == nil)
      {
          returnedAnnotationView =
          [[CustomAnnotationView alloc] initWithAnnotation:annotation
                                           reuseIdentifier:@"Annotation"];
      }
  
      return returnedAnnotationView;
  }
  
  @end
  </code></pre>
  
  <p><strong>CustomAnnotationView.h</strong></p>
  
  <pre><code>@interface CustomAnnotationView : MKAnnotationView
  </code></pre>
  
  <p><strong>CustomAnnotationView.m</strong></p>
  
  <pre><code>- (id)initWithAnnotation:(id &lt;MKAnnotation&gt;)annotation reuseIdentifier:(NSString *)reuseIdentifier
  {
  
      self = [super initWithAnnotation:annotation reuseIdentifier:@"Annotation"];
      if (self != nil)
      {
          Annotation *mapItem = (Annotation *)self.annotation;
  
          // Create imageView and labels, etc.
      }
  
      return self;
  }
  </code></pre>
  
  <p>Then, to drop my annotation, I have this method which loops through an array of contacts, gets their address, finds the CLLOcationCoordinate2D, and creates an <code>Annotation</code>.</p>
  
  <pre><code>-(void)sortContacts{
  
      for (APContact *contact in self.peopleArray){
  
            [operationQueue addOperationWithBlock:^{
  
              NSString *addressString = // get address from contact;
  
              contact.addressString = addressString;
  
                  CLGeocoder *geocoder = [[CLGeocoder alloc] init];
                  [geocoder geocodeAddressString:addressString
                               completionHandler:^(NSArray* placemarks, NSError* error){
                                   if (placemarks &amp;&amp; placemarks.count &gt; 0 &amp;&amp; !error) {
  
                                       CLPlacemark *topResult = [placemarks objectAtIndex:0];
                                       CLLocation *location = topResult.location;
                                       CLLocationCoordinate2D coordinate = location.coordinate;
  
                                           Annotation *annotation = [[Annotation alloc] init];
                                           annotation.image = [UIImage imageNamed:@"Annotation"];
  
                                           if (contact.thumbnail.size.width &gt; 0){
                                              annotation.image = contact.thumbnail;
                                           }
                                           else{
                                              annotation.image = [UIImage imageNamed:@"Annotation"];
                                           }
  
                                           annotation.coordinate = coordinate;
                                           [self.mapView addAnnotation:annotation];
                                   }
                                   else if (error){
                                       NSLog(@"ERROR");
                                   }
                              }
                   ];
          }];
      }
  }
  
  -(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id&lt;MKAnnotation&gt;)annotation{
  
      CustomAnnotationView *returnedAnnotationView = nil;
  
             if ([annotation isKindOfClass:[Annotation class]])
          {
              returnedAnnotationView = (CustomAnnotationView *)[Annotation createViewAnnotationForMapView:self.mapView annotation:annotation];
          }
  
      return returnedAnnotationView;
  }
  </code></pre>
  
  <p>However, when I scroll across <code>self.mapView</code>, the incorrect contact images are showing for the wrong annotations. I'm not sure how to fix this.  Any help would be much appreciated.  Thanks</p>