我使用instantiateViewControllerWithIdentifier(identifier: String)
函數從ViewControllerA創建ViewControllerB的實例。如何使用swift將數據從viewcontroller A傳遞到另一個viewcontroller 3
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("vcB") as VCB;
rootController!.presentViewController(vc, animated: true, completion: nil)
class VCB: UIViewController {
required init?(coder aDecoder: NSCoder){
super.init(coder: aDecoder)
}
}
我想訪問我已經在我的ViewControllerB中傳遞的值我怎麼能實現這一點。
我已經通過了 Passing Data between View Controllers鏈接,但在目標c中的答案。
有很多方法,你可以從一個視圖控制器將數據傳遞到另一個視圖 - 控制喜歡使用NSNotification中心,委託,PrepareforSegue,並使用對propertyList –
您鏈接的問題有很多答案,斯威夫特也。 – rmaddy