简体   繁体   中英

Passing Data From Parent View Controller to Child View Controller Swift 4

I am trying to send data from parent view controller (Container View) to its child view controller.

I've tried sending data via segue but I got this error " Could not cast value of type 'UIViewController' (0x10d30d1f0) to 'ContainerDeom.ChildVC' "

ContainerDeom: is the project name

ChildVC: The child of container view

Try this code

if let controller = (self.childViewControllers.filter {$0 is urChildController}).first {
    // assign ur parsed data of parent controller to your child controller 
    controller.dict = self.urResponseDict

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM