I am trying to pass data from a map view about an point annotation whenever the right detail accessory is tapped to another view that will display more information about the point annotation that isn't displayed in the callous view. I know I need to use override function prepareForSegue
but how do I properly set it up to do what I want. The other information about the point annotation is coming from Parse so I'm assuming I will have to set up a query as well. Please help!
Thanks!!!
You can use NSUserDefaults
to pass a value from your map view to another view this way:
func mapView(mapView: MKMapView!, annotationView view: MKAnnotationView!, calloutAccessoryControlTapped control: UIControl!) {
let title = view.annotation.title
NSUserDefaults.standardUserDefaults().setObject(title, forKey: "mapTitle")
performSegueWithIdentifier("mapToCity", sender: self)
}
In your next view you can get values this way:
override func viewDidLoad() {
super.viewDidLoad()
let foo1 = NSUserDefaults.standardUserDefaults().objectForKey("mapTitle") as! String
println(foo1)
}
For more Info check THIS sample project.