-2

I need to pass some data from VC1 to the container of VC2, but the fact is that the container loads before than VC2 so I can't get the data just using parentViewController.data, so is there anything I can do to get the data from VC1 to the container of VC2 and loading it before VC2 does the ViewWillLoad function? I need to do it in swift.

Maybe there is some extra segue path like in tabBarController or NavigationController?

JAL
  • 41,701
  • 23
  • 172
  • 300
Cano
  • 13
  • 5
  • 4
    Lots of questions and answers on this: http://stackoverflow.com/questions/5210535/passing-data-between-view-controllers – Lukesivi Dec 01 '15 at 20:37
  • Not with containers mate, I have done a lot of research but with no result. – Cano Dec 02 '15 at 08:29

1 Answers1

0

I found my own solution, i only had to get the parent data in function ViewWillAppear instead of ViewDidLoad. For some reason the creation order of parent and child views are: 1. VC2-container ViewDidLoad() 2. VC2 ViewDidLoad() 3. VC2-container ViewWillAppear()

So just by getting the data on ViewWillAppear will always get a not null atribute because it will have been set.

Cano
  • 13
  • 5