我有VC“ A”,从中我将一些数据传递给“ B”。在属性检查器中,我称我的定语为“ B”:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "B" {
let vc = segue.destination as! ChooseController
vc.someData = "passedDataFromAToB"
}
之后,我想使用委托和协议将一些数据从B传递回A,但事实证明我的segue标识符很忙。我必须创建新的segue吗?但是,如何以编程方式?
答案 0 :(得分:0)
您需要在此处设置代表
let vc = segue.destination as! ChooseController
vc.delegate = self
vc.someData = "passedDataFromAToB"
class ChooseController:UIViewController {
weak var delegate:AVC?
然后在解雇之前传递数据
delegate?.sendData(data)
self.dismiss(animated:true,completion:nil)