Noura Aziz
Noura Aziz

Reputation: 57

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

Upvotes: 0

Views: 938

Answers (1)

Mahesh Dangar
Mahesh Dangar

Reputation: 804

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

}

Upvotes: 2

Related Questions