0

My problem is:

I have a viewControllers A and B. I go from A to B using a segue.

viewController B has two children (B1 and B2) and both need the same data passed from A.

How can I pass data from A to child B1 and B2?

At that moment I can only pass data to B.

1 Answers1

0

The way to do this is to pass the data to the UIViewController B from the UIViewController A via the segue.

Afterwards, in the UIViewController B, when you implement the method override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] you should create B1 and B2 controllers. After the creation of them, you should set the pertinent information to each one.

var data = "The data passed from A"

override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController]
    let firstChild = B1()
    let secondChild = B2()
    firstChild.data = self.data
    secondChild.data = self.data
    return [firstChild, secondChild]
}

Hope it helps!

Federico Ojeda
  • 758
  • 7
  • 11