I have a UIViewController VC opened modally.
This viewcontroller, built with a storyboard, contains a navigation bar and a container view.
The container view embeds a UIPageViewController.
The UIPageViewController has its own class.
From this class I need to access to a member of the parent UIViewController (OR, in my case it's the same, pass a value to the child view controller).
How to do it?
I tried to print out the self.parent and self.presentingViewController but it turns out their values are both nil.
I tried another thing too, but it's not performing very well: in UIViewController I refer to the child view controller this way:
var pVC = self.childViewControllers[0] as! PageViewController
this way I can pass a value to the pageViewController:
pVC.myVariable = "Blue"
but I can read it only in viewDidAppear, not in viewDidLoad (and it's slow).
I even tried to do a similar thing in the context of a didSet: it works way better but I don't know if this is very othodox.