title: iPhone : How to get values from class in viewForAnnotation method?
body: <p>I am trying to show two images on Map on base of Points name.</p>
  
  <pre><code>@interface MyAnnotationClass : NSObject &lt;MKAnnotation&gt; {
      NSString *_name;
      NSString *_description;
      CLLocationCoordinate2D _coordinate;
  
  
  }
  @property (nonatomic, retain) NSString *name;
  @property (nonatomic, retain) NSString *description;
  @property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
  
  -(id) initWithCoordinate:(CLLocationCoordinate2D) coordinate;
  </code></pre>
  
  <p>ViewDidLoad method code : </p>
  
  <pre><code>mapView.delegate = self;
      //Initialize annotation
      MyAnnotationClass *commuterLotAnnotation=[[MyAnnotationClass alloc] initWithCoordinate:CLLocationCoordinate2DMake( 39.047752, -76.850388)];
      commuterLotAnnotation.name = @"1";
      MyAnnotationClass *overflowLotAnnotation=[[MyAnnotationClass alloc] initWithCoordinate:CLLocationCoordinate2DMake(  39.047958, -76.852520)];
      overflowLotAnnotation.name = @"2";
  
      //Add them to array
      self.myAnnotations=[NSArray arrayWithObjects:commuterLotAnnotation, overflowLotAnnotation, nil];
  
      //Release the annotations now that they've been added to the array
      [commuterLotAnnotation release];
      [overflowLotAnnotation release];
  
      //add array of annotations to map
      [mapView addAnnotations:_myAnnotations];
  </code></pre>
  
  <p>viewForAnnotation code : </p>
  
  <pre><code>-(MKAnnotationView *)mapView:(MKMapView *)MapView viewForAnnotation:(id&lt;MKAnnotation&gt;)annotation{
      static NSString *parkingAnnotationIdentifier=@"ParkingAnnotationIdentifier";
  
      if([annotation isKindOfClass:[MyAnnotationClass class]]){
  
          //Try to get an unused annotation, similar to uitableviewcells
          MKAnnotationView *annotationView=[MapView dequeueReusableAnnotationViewWithIdentifier:parkingAnnotationIdentifier];
          //If one isn't available, create a new one
          if(!annotationView){
              annotationView=[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:parkingAnnotationIdentifier];
             /* if(imgCount == 0){
                  annotationView.image=[UIImage imageNamed:@"passenger.png"];
                  imgCount = 1;
              }
              else if(imgCount == 1){
                  annotationView.image=[UIImage imageNamed:@"place.png"];
                  imgCount = 0;
              }*/
             // if([((MyAnnotationClass)annotation).name isEqualToString: @"1"])
              // code to show image
          }
          return annotationView;
      }
      return nil;
  }
  </code></pre>
  
  <p>Now I want to access name member of MyAnnotationClass in viewForAnnotation to decide point and image on base of point. e.g.
    if([((MyAnnotationClass)annotation).name isEqualToString: @"1"])</p>
  
  <p>but it does not work and show exception on ((MyAnnotationClass)annotation)</p>
  
  <p>Please help.</p>