I wish to pass informations from a Pin annotation to another viewController.I can pass the title and subtitle of the annotation but I need to pass some extra information along with these. Is there a way to add extra information to a MKPointAnnotation other than just title and subtitle?
here I have the pin title and subtitle set so it appears on the map:
var zoopin = MKPointAnnotation()
zoopin.coordinate = zoo
zoopin.title = "The zoo"
zoopin.subtitle = "hello this is the zoo"
mapView.addAnnotation(zoopin)
the title and subtitle are then passed to my info view controller using:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if (segue.identifier == "info") {
if let annotation = sender as? MKAnnotationView {
let detailViewController = segue.destinationViewController as! info
detailViewController.titleText = annotation.annotation?.title ?? ""
detailViewController.detaileText = annotation.annotation?.subtitle ?? ""
}
}
}