title: Adding onClick event to MKAnnotation swift
body: <p>I am currently getting some locations from a web request using alamofire, store them in my Object array and then display them on a MKMapView.</p>
  
  <pre><code> func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -&gt; MKAnnotationView? {
      guard !(annotation is MKUserLocation) else {
          return nil
      }
  
      let annotationIdentifier = "AnnotationIdentifier"
  
      var annotationView: MKAnnotationView?
      if let dequeuedAnnotationView = mapView.dequeueReusableAnnotationView(withIdentifier: annotationIdentifier) {
          annotationView = dequeuedAnnotationView
          annotationView?.annotation = annotation
      }
      else {
          annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: annotationIdentifier)
          annotationView?.rightCalloutAccessoryView = UIButton(type: .detailDisclosure)
      }
  
      if let annotationView = annotationView {
          annotationView.canShowCallout = true
          annotationView.image = UIImage(named: "atm_map_icon")
      }
  
      return annotationView
  }
  </code></pre>
  
  <p>And here is where i parse the json, put the result in an array and the loop through the array and add the markers to the map</p>
  
  <pre><code>for var i in 0..&lt;json.count{
                  let name = json[i]["Name"].string
                  let address = json[i]["Address"].string
                  let lat = json[i]["Lat"].double
                  let lon = json[i]["Lon"].double
                  let atm = Atm(name: name!,address: address!,lat: lat!,lon: lon!)
                  self.atmArrayList.append(atm)
  
  
  
              }
              print(self.atmArrayList.count)
          }
          for atm in self.atmArrayList{
              let atmPin = AtmAnnotation(title: atm.name!, subtitle: atm.address!, atm: atm, coordinate: CLLocationCoordinate2D(latitude: atm.lat!, longitude: atm.lon!))
              self.annotationArray.append(atmPin)
          }
  
          self.atmMapView.addAnnotations(self.annotationArray)
  </code></pre>
  
  <p>What i want to achieve is so when the user clicks on the rightCalloutAccessoryView button, i want to pass the specific Atm object of that Annotation to the another ViewController. </p>
  
  <p>My guess is to give the Annotations an id and then get the Atm from the Atm array in that specific position??</p>