从JSON获取价值并传递到另一个视图

时间:2018-12-06 14:19:53

标签: ios swift uiviewcontroller pass-data

我必须从JSON获取值,并将此字符串传递给第二个View中的变量。因此,我的问题是因为这样做,所以无法从JSON中获得价值。我该怎么做。我刚刚尝试过准备(用于segue)和其他代码,但是任何有效的方法。您有什么建议吗?

我希望我已经更清楚了。抱歉。 1)First 2)Second

1 个答案:

答案 0 :(得分:0)

这应该做到。

let mainStoryboard = UIStoryboard.init(name: "Main", bundle: nil)
let homeViewController = mainStoryboard.instantiateViewController(withIdentifier: "Your Home View Controller identifier") as! SecondView
homeViewController.title = self.title
homeViewController.description = self.description
self.navigationController?.pushViewController(homeViewController, animated: true)