I am trying to Compile my app again now that Swift 2 is out and the thing is I am having an error with TabBarController instances.
I am declaring the instances in vars in order to use methods from anothers ViewControllers.
Here it's my code:
let barViewControllers = self.tabBarController?.viewControllers
let listViewController = barViewControllers![2].viewControllers![0] as! dbViewController //The [2] is because it's the third TabBar and the [0] it's because It's embebed in a NavigationController.
let calendarViewController = barViewControllers![1] as! CalendarViewController
In the second line Im having the following error:
UIViewController does not have a member named "viewControllers"
Anybody could help me?
Thanks
You are trying to access the property
viewControllersof the typeUIViewController, which it doesn't have.viewControllersis a property on aUITabBarController, butviewControllersreturns an array ofUIViewController.Cast
viewControllersto an array ofUITabBarController(or only the item you extract) to access it'sviewControllerproperty.Like this:
Or this: