Reputation: 59
Storyboard screenshot with description
I've used this line of code in the UIViewController
class of 2nd tab to access the tabBarViewController
. But it crashes.
let friendView = self.tabBarController?.viewControllers![2] as! AccountTableViewController
Note: AccountTableViewController
is the name of UITableViewController
class of 3rd tab.
Thanks for your help.
Upvotes: 2
Views: 681
Reputation: 72410
Change your code like this
let navController = self.tabBarController?.viewControllers![2] as! UINavigationController
for vc in (self.navigationController?.viewControllers)! {
if (vc.isKindOfClass(AccountTableViewController.classForCoder())) {
let friendView = vc as! AccountTableViewController
}
}
Upvotes: 3