Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

in this case i have tabbar controller and navigation controller between the two VC,which means firstly i want to pass data between the first VC and the tabbar controller, and secondly i want to pass the same data from the tab bar controller to navigation controller , and finnally to the last VC,i searched for example in the net but i didn't find anything useful.


pass data

please can u help me pass data between these two viewcontrollers ,any example will be great, thaank's.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
182 views
Welcome To Ask or Share your Answers For Others

1 Answer

Set an identifier to the segue in your storyboard (click on the segue and then on the right menu go to attributes inspector) and then you probably need to click on the cell to make the segue in didSelectRowAt, do this in there:

self.performSegue(withIdentifier: "YOUR IDENTIFIER", sender: DATA TO PASS or nil)

And then create the segue function

override func prepare(for segue: UIStoryboardSegue, sender: Any!){
    if (segue.identifier == "YOUR IDENTIFIER") // good to have if you have multiple segues
    {
        let secondVC = segue.destination as! SecondViewController
        secondVC.str = "DATA" // now you can access public variables and functions from the second viewController
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...