如何在swift中使用alamofire将Json数组值从父视图控制器传递到子视图控制器

时间:2018-01-04 06:56:14

标签: ios json swift childviewcontroller parentviewcontroller

我在parentviewcontroller收到Json回复,我想将该回复中的数组值传递给childviewcontroller

1 个答案:

答案 0 :(得分:0)

试试这种方式

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]() 
...
}