我想将json数组从一个视图控制器发送到另一个视图控制器,并且该数组应该在pickerview中填充。但我无法发送数组。我正在获得阵列但无法发送它
let mydata = json["data"] as! NSArray
print("My Data is \(mydata)")
var sendData = [NSArray]()
sendData = mydata as! Array<NSArray>
self.performSegue(withIdentifier: "checkLoginViewController", sender: sendData)
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let destinationVC = segue.destination as? SignupViewController, let sendData = sender as? [String]{
destinationVC.dept = sendData
}
}
secondVC:
var dept = [String]()
答案 0 :(得分:2)
问题是你使用Array<NSArray>
endData = mydata as! Array<NSArray>
并准备演员喜欢
let sendData = sender as? [String]
肯定会失败
答案 1 :(得分:0)
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let destinationVC = segue.destination as? SignupViewController, let sendData = sender as? {
destinationVC.dept = sendData
}
}
试试这段代码