title: mapkit and annotations
body: <p>I am very new to XCode and iPhone development so please bear with me if this question is too simple. But I have a map and I have successfully added images (not pins) to it for my annotations. And I can change the image when the user selects one of the annotations.</p>
  
  <p>I created a class that inherits from MKAnnotationView with the following methods:-</p>
  
  <pre><code>- (id)initWithAnnotation:
  
  - (void)setAnnotation:
  
  - (void)drawRect:
  </code></pre>
  
  <p>and I am using</p>
  
  <pre><code>- (void)touchesBegan
  </code></pre>
  
  <p>to know when an annotation has been selected. And in touchesBegan I am doing :-</p>
  
  <pre><code>UIImage *i = [UIImage imageNamed:@"A.png"];
  self.image = i;
  </code></pre>
  
  <p>to change the image. But what I am really stumped on is how do I change the image back to it's original image when the users selects the next annotation. I have tried:-</p>
  
  <pre><code>NSArray *selectedAnnotations = map.selectedAnnotations;
  for(id annotationView in selectedAnnotations) {
  [map deselectAnnotation:[annotationView annotation] animated:NO];
  }
  </code></pre>
  
  <p>but it errors</p>
  
  <p>and I tried</p>
  
  <pre><code>for (MKAnnotationView *ann in map.selectedAnnotations){
  if ([ann isMemberOfClass:[Place class]])
  {
  place = (Place *)ann;
  NSLog(@"second = %@"@" %f"@" %f", place.title, place.longitude, place.latitude);
  if (currentPlaceID == place.placeID) {
  //UIImage *i = [UIImage imageNamed:@"A.png"];
  
  //ann.image = i;
  }
  else {
  UIImage *i = [UIImage imageNamed:@"pin.png"];
  
  ann.image = i;
  }
  }
  
  }
  </code></pre>
  
  <p>the above code works ok until I get to ann.image = i; then it errors. The errors I get are:-</p>
  
  <pre><code>*** -[Place setImage:]: unrecognized selector sent to instance 0x4514370
  *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[Place setImage:]: unrecognized selector sent to instance 0x4514370'
  </code></pre>
  
  <p>Yes I can see that my place object does not have an image so that's why it is going wrong.  But if I create an image property on my place object - how will that change the annotations image which what I am trying to do.</p>
  
  <p>Please advise as I have been going around in circles on this one for 2 days now!!!!</p>
  
  <p>Thanks in advance
  Cheryl </p>