0

I have 3 ViewControllers, A, B and C. My navigation stack is like A -> B and B-> C. Now I want to pass data back to controller A from Controller C. Is there any way to send data directly from ViewController C to ViewController A?

Thanks in advance

1 Answers1

0

For navigation stack , Your scenario is A->B->C so stack is [A,B,C] . You can reach expected ViewController with using

 let viewControllerA = self.navigationController!.viewControllers[0] as! AViewController // 0 is viewcontroller index which in stack.

then when you want to send data to this vc or changing some data in this vc you can reach it with

viewControllerA.changingVariable = "bla bla"
Omer Tekbiyik
  • 4,255
  • 1
  • 15
  • 27