如何在我的 UITabBarViewController 的代码中调用我的 UIViewController 中的内容?

How do I call something in my UIViewController in the code of my UITabBarViewController?

我想在 ViewController(类型 "MatchesViewController",它位于我的 TabBarViewControlleer 的第 3 个选项卡上)上调用一个方法,如果所选项目不属于那个 class。

这是我的委托函数,用于在选项卡栏项目更改时进行监听。

override func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem!) {

}

在此代码中,我想检测所选项目(及其视图控制器)是否属于 "MatchesViewController" 类型。如果不是这种类型,则调用该控制器上的方法。

为什么不使用 tabBarController(_:didSelectViewController:)

override func tabBarController(tabBarController: UITabBarController,
   didSelectViewController viewController: UIViewController) 
{
    if !(viewController is MatchesViewController) {
        let matchesVC = tabBarController.viewControllers?[2] as MatchesViewController
        matchesVC.refresh()
    }
}