I have one UIViewController with two containers. Each of those containers contains one UIViewController. On the parent view controller I have the segmented control that lets user decide which controller should be currently visible:
@IBOutlet weak var firstView: UIView!
@IBOutlet weak var secondView: UIView!
@IBAction func indexChanged(sender: UISegmentedControl) {
    switch segmentedControl.selectedSegmentIndex {
    case 0:
        firstView.hidden = true
        secondView.hidden = false
    case 1:
        firstView.hidden = false
        secondView.hidden = true
    default:
        break;
    }
}
Now, in each of the two embedded UIViewControllers I have a viewDidLoad function:
override func viewDidLoad(){
    print("first container")
and:
override func viewDidLoad(){
    print("second container")
and my problem is: when user enters the parent view controller he immediately sees in the console:
first container
second container
even though only the first container is visible and the second one is not.
I would like to distinguish which container is currently visible, so that when user enters the parent view controller and sees the first container, he should see only first container in the console. And after hitting the segmented control he should see second container, and so forth. 
I tried to add those prints in viewWillAppear but they both load at the same time. How should I modify my code to achieve such effect?
