【发布时间】:2018-01-04 06:56:13
【问题描述】:
我在 parentviewcontroller 中收到 Json 响应,我想将该响应中的数组值传递给 childviewcontroller。
【问题讨论】:
-
您可以在子视图控制器中设置属性并将值传递给它。没有必要使用 alamfire。
标签: ios json swift childviewcontroller parentviewcontroller
我在 parentviewcontroller 中收到 Json 响应,我想将该响应中的数组值传递给 childviewcontroller。
【问题讨论】:
标签: ios json swift childviewcontroller parentviewcontroller
试试这个方法
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]()
...
}
【讨论】: