Pass data between ViewController and TabBarController

后端 未结 4 1463
旧巷少年郎
旧巷少年郎 2021-02-09 07:07

I have couple of questions. How to pass the data (which i got after the Alamofire request is finished), to one of children of TabBarController?

The first problem i have

4条回答
  •  失恋的感觉
    2021-02-09 07:36

    For Xcode 8, Swift 3.x you can use something like the following. This assumes you have your view controller embedded in a navigation controller. In my situation, I am trying to set a variable called startWizard to true when navigating from the new user setup view.

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        if (segue.identifier == "segueFromNewUserToDashboard") {
            let dashboardController = segue.destination as! MyTabBarController
            for viewController in dashboardController.viewControllers! {
                let navViewController = (viewController as! MyNavigationController).topViewController!
                if (navViewController.isKind(of: DashboardViewController.self) == true) {
                    (navViewController as! DashboardViewController).startWizard = true
                    break
                }
            }
        }
    }
    

提交回复
热议问题