0

I want to pass the data (quelmonument) from a pinpoint on a Mapkit to another viewcontroller. With this code just below, i could get the good value but i don't know i could do to pass the data.

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

        if control == annotationView.rightCalloutAccessoryView {

            if let pinannotation = annotationView.annotation as? Artwork{

                println("status was = \(pinannotation.quelmonument)")

                var indexmonument = pinannotation.quelmonument


                   performSegueWithIdentifier("hugo", sender: self)

            }

        }

     }

I have tried to send the value 2, and it's working, but instead of 2 i would like send "quelmonument" variable. Could you give me pls an hint ?

func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        if segue.identifier == "hugo"
        {
            if let destinationVC = segue.destinationViewController as? MonumentViewController{
                destinationVC.numberToDisplay = 2


            }

        }
    }
Hugo75
  • 239
  • 2
  • 14
  • You could add a nulled variable of the same type in the destination view controller and then set the variable to the reference of ```quelmonument``` I'd be more specific however I don't know what the type is of ```quelmonument``` – Patrick Zawadzki Jun 25 '15 at 19:53
  • 2
    instead of making indexmonument a local variable make it a member variable of the VC class thats all. Then in prepareForSeque just call destinationVC.numberToDisplay = self.indexmonument – Gruntcakes Jun 25 '15 at 19:55
  • could you help me more pls ? how could you do that ? – Hugo75 Jun 25 '15 at 20:29
  • class ViewController { var indexmonument = 0 could i add something like that ? – Hugo75 Jun 26 '15 at 11:30
  • 1
    You will need to [read this](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TypeCasting.html) and learn more about [delegates](https://stackoverflow.com/questions/25522912/passing-data-back-from-view-controllers-xcode-v6b5-swift) which can help you with passing data. – Patrick Zawadzki Jun 26 '15 at 13:44

0 Answers0