Change MKAnnotation Pin Color
<p>I have an array of Meetup objects that display on a map as red pins. I would like to change the color of the pin based on an attribute of eachhe Meetup object. Each Meetup has a category. If the first Meetup in the array has a Category A, I would like the pin to be red, and if the second Meetup has a Category B, I would like the pin to be blue (And so on). I am trying to do this in viewForAnnotation.</p>

<p>Here is some of my code:</p>

<pre><code>func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -&gt; MKAnnotationView? {

  if annotation is Meetup {

    let identifier = "Location"
    var annotationView = mapView.dequeueReusableAnnotationViewWithIdentifier(identifier) as! MKPinAnnotationView!
    if annotationView == nil {
      annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: identifier)

      annotationView.enabled = true
      annotationView.canShowCallout = true
      annotationView.animatesDrop = false
      annotationView.pinTintColor = UIColor(red: 255/255, green: 36/255, blue: 0, alpha: 1)
      annotationView.tintColor = UIColor(white: 0.0, alpha: 0.5)
</code></pre>

<p>I am trying to do something in here like:</p>

<pre><code>if annotation is Meetup where Meetup.category == "Category A" {
          annotationView.pinTintColor = UIColor(red: 255/255, green: 36/255, blue: 0, alpha: 1)
} else if annotation is Meetup where Meetup.category == "Category B" {
          annotationView.pinTintColor = UIColor(red: 0, green: 36/255, blue: 255/255, alpha: 1)
</code></pre>

<p>Can someone please point me in the right direction on how to get this accomplished?</p>

<p>Thanks!</p>