0

How do I communicate from parent to child view controller once a view is loaded? I want to communicate from parent to child without notification any idea?. from child to parent I can use protocol and delegates

Shoaib Pathan
  • 149
  • 1
  • 5

1 Answers1

0

You can use delegation but there is no need of doing it, you can directly access the child viewControllers from the parent viewController. as we know that we can access all the child viewController from parent viewController.

let viewControllersArray = self.childViewControllers
let viewController = viewControllersArray[index] as? YouViewController

or if you dont know the index of your viewController

let viewControllersArray = self.childViewControllers
for viewController in viewControllersArray {
      if let viewController as? YouViewController {
                // your stuff
      }
}
Ajay saini
  • 2,352
  • 1
  • 11
  • 25