I'm a beginner in programming, so got a question. I have an app with 3 viewControllers. First 2 has inputs. So, the question is, how can I pass data from 1st and 2nd VC to the third one? Thanks a lot for help.
Asked
Active
Viewed 572 times
-1
-
1The same question has been asked many times. – El Tomato Nov 19 '16 at 23:09
1 Answers
0
Most use segues between each view controller typically (VC#1 >> VC2 >> VC3). If you are doing that, you simply need to declare public properties along the route and pass them.
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "Segue VC #2" {
if let vc = segue.destination as? SecondViewController {
vc.property1 = self.propertyToSend
}
}
}
-
3But which segue should I use, if I want to pass ny data from 1st and 2nd VC to 3rd? 1>3, 2>3 or 1>2>3? – Valentine Mytchyk Nov 20 '16 at 07:03