How to pass a Json array value from parent viewcontroller to child viewcontroller using alamofire in swift

72 Views Asked by At

I am getting Json response in my parentviewcontroller and I want to pass the array value from that response to a childviewcontroller.

1

There are 1 best solutions below

0
Shezad On

Try this way

class parentVC: UIViewController {
...
let childController = UIStoryboard(name: "Storyboard-Name", bundle: nil).instantiateViewController(withIdentifier: "Child Viewcontroller Id") as? ChildVC
childController.arrayFromParent = arrayToPass //You can pass value to a variable in child viewcontroller.

}

class ChildVC: UIViewController {
var arrayFromParent = [String]() 
...
}