Passing data to segue from annotation?

I have a mapView with annotations that are created using data from CloudKit. I use the info button from the annotation to call the segue when the button is tapped.

I know that I can pass title and subtitle easily like this..

func mapView(mapView: MKMapView, annotationView: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {

    let detailTitle = annotationView.annotation.title

    performSegueWithIdentifier("fromMap", sender: self)

}

My issue is that I need to send more than just the data that is inside the MKAnnotation view. I have a few other fields from the CloudKit records that I need to pass along through the segue to the detail controller, but I can't for the life of me figure out how to do that.

It's easy to do with a tableView because you have the indexPath info, but you don't have that from an annotation as far as I can tell.

I've looked through all the posts and info I could find online, but I'm still stuck.

Any help would be appreciated.

Answers


You can use tuple just to send more than one object and catch them from the target view controller

func mapView(mapView: MKMapView, annotationView: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
  let detailTitle = annotationView.annotation.title
  performSegueWithIdentifier("fromMap", sender: (annotation.title, annotation.subtitle, annotation.address))
}

Need Your Help

Trying to pass variable to window.location.hash

javascript hash

Having some difficulty getting this to work.

Add Class using GetElementsByClassName JavaScript

javascript css

I am converting a jQuery site to vanilla javascript and am reaching out for advice on the best way to convert a simple line of jQuery to javascript.