title: Change pin image on MKMapView in Swift
body: <p>I am trying to change pin image on the MKMapView in Swift, but unfortunately it don't work. Any Idea what I am doing wrong ? I saw some examples here, but did not worked.</p>
  
  <pre><code>import UIKit
  import MapKit
  
  class AlarmMapViewController: UIViewController {
      @IBOutlet weak var map: MKMapView!
  
      override func viewDidLoad() {
          super.viewDidLoad()
          showAlarms()
          map.showsUserLocation = true
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
      }
  
      func showAlarms(){
  
          map.region.center.latitude = 49
          map.region.center.longitude = 12
          map.region.span.latitudeDelta = 1
          map.region.span.longitudeDelta = 1
  
          for alarm in Alarms.sharedInstance.alarms {
  
              let location = CLLocationCoordinate2D(
                  latitude: Double(alarm.latitude),
                  longitude: Double(alarm.longtitude)
              )
  
              let annotation = MKPointAnnotation()
              annotation.setCoordinate(location)
              annotation.title = alarm.name
              annotation.subtitle = alarm.description
              mapView(map, viewForAnnotation: annotation).annotation = annotation
              map.addAnnotation(annotation)
          }
      }
  
      @IBAction func zoomIn(sender: AnyObject) {
      }
  
      @IBAction func changeMapType(sender: AnyObject) {
      }
  
      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!.image = UIImage(named:"GreenDot")!
  
          }
          else {
              pinView!.annotation = annotation
          }
  
          return pinView
      }
  }
  </code></pre>
  
  <p>GreenDot picture is available and used on other places.</p>