title: Display different images for every annotation on mapView in Swift
body: <p>Working with MapKit and Swift, I am trying to display a number of annotations with each having a unique image to display in the leftCalloutAccessoryView.  I am able to display annotations with different titles and subtitles; however, the image that is displayed for every annotation is the same image - I am having trouble figuring out how to make every image unique.  Much appreciation on any and all feedback/guidance to getting this to work.  Code below (p.s. I am aware I have hard-coded an image; I am unsure how to iterate through each annotation to display the appropriate images):</p>
  
  <pre class="lang-swift prettyprint-override"><code>override func viewDidLoad() {
      super.viewDidLoad()
  
      mySearch.delegate = self
      theMapView.delegate = self
  
      var latAustin:CLLocationDegrees = 30.274751
      var lngAustin:CLLocationDegrees = -97.739141
  
      var latAustinDelta:CLLocationDegrees = 0.1
      var lngAustinDelta:CLLocationDegrees = 0.1
  
      var theSpan:MKCoordinateSpan = MKCoordinateSpanMake(latAustinDelta, lngAustinDelta)
      var austinLocation:CLLocationCoordinate2D = CLLocationCoordinate2DMake(latAustin, lngAustin)
      var theRegion:MKCoordinateRegion = MKCoordinateRegionMake(austinLocation, theSpan)
  
      theMapView.setRegion(theRegion, animated: true)
      //        println(theMapView.userLocation.coordinate.latitude)
      //        println(theMapView.userLocation.coordinate.longitude)
  
      for var i = 0; i &lt; politicians.count; i++ {
          var politician = MKPointAnnotation()
  
          var politicianTotalFunding:String = politicians[i]["totalFunding"]! as String
  
          politician.coordinate = CLLocationCoordinate2DMake(politiciansCoords[i]["lat"]! as CLLocationDegrees, politiciansCoords[i]["lng"]! as CLLocationDegrees)
          politician.title = politicians[i]["name"]! as String
          politician.subtitle = "Total Funding: \(politicianTotalFunding)"
  
          theMapView.addAnnotation(politician)
      }
  }
  
  
  // Delegate method called each time an annotation appears in the visible window
  func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -&gt; MKAnnotationView! {
  
      if annotation is MKUserLocation {
          //return nil so map view draws "blue dot" for standard user location
          return nil
      }
  
      let reuseId = "pin"
  
      var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) as? MKPinAnnotationView
      if pinView == nil {
          pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
          pinView!.canShowCallout = true
          pinView!.animatesDrop = true
          pinView!.pinColor = .Red
  
          var imageview = UIImageView(frame: CGRectMake(0, 0, 45, 45))
          imageview.image = UIImage(named: politicians[0]["photo"])
          pinView!.leftCalloutAccessoryView = imageview
  
          pinView!.rightCalloutAccessoryView = UIButton.buttonWithType(.DetailDisclosure) as UIButton
      } else {
          pinView!.annotation = annotation
      }
      return pinView
  }
  </code></pre>
  
  <p>Thanks again so much for all your help!</p>