Swift pass data through navigation controller

后端 未结 8 2126
青春惊慌失措
青春惊慌失措 2020-12-12 18:13

One of my segues transitions from a view controller to a tableview controller. I want to pass an array between the two, but with a navigation controller before the tableview

8条回答
  •  我在风中等你
    2020-12-12 18:34

    @Tommy Devoy's answer is correct but here is the same thing in swift 3

    Updated Swift 3

      // MARK: - Navigation
    
    //In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    
    
        if segue.identifier == "yourSegueIdentifier"  {
    
            if let navController = segue.destination as? UINavigationController {
    
                if let chidVC = navController.topViewController as? YourViewController {
                     //TODO: access here chid VC  like childVC.yourTableViewArray = localArrayValue 
    
    
                }
    
            }
    
        }
    
    }
    

提交回复
热议问题