[ad_1]
So I must cross knowledge from ThirdVC to FirstVC so principally cross the delegate by way of the second protocol, after which the information by way of the First protocol I am uncertain how I’d do it, that is UIKIT and Storyboard under is what I’ve thus far, it really works however I want it to do what I am asking above.
protocol FirstCall {
func firstFunction(makerData: String,featuresData: [String])
}
class FirstVC: UIViewController, FirstCall {
var delegate: FirstCall?
@IBAction func buttonClicked(_ sender: Any) {
guard let SecondVC = storyboard?.instantiateViewController(identifier: "SecondVC") as? SecondVC else {return}
SecondVC.delegate = self
navigationController?.pushViewController(SecondVC, animated: true)
}
func firstFunction(makerData: String,featuresData: [String]) {
print(makerData)
print(featuresData)
}
}
protocol SecondCall {
func secondFunction(makerData: String,featuresData: [String])
}
class SecondVC: UIViewController, SecondCall {
var delegate: FirstCall?
@IBAction func buttonClicked(_ sender: Any){
guard let ThirdVC = storyboard?.instantiateViewController(identifier: "ThirdVC") as? ThirdVC else {return}
ThirdVC.delegate = self
navigationController?.pushViewController(ThirdVC, animated: true)
}
func secondFunction(makerData: String,featuresData: [String]){
delegate?.firstFunction(makerData: makerData,featuresData: featuresData)
}
}
class ThirdVC: UIViewController {
var delegate: SecondCall?
@IBAction func buttonClicked(_ sender: Any) {
self.navigationController?.popToRootViewController(animated: true)
delegate?.secondFunction(makerData: makerData,featuresData: featuresData)
}
}
[ad_2]
