In the storyBoard "parent" scene with its parentVC.swift, there are 2 containerVC with embedded segues with their containerVC.swift for each.
In container1, a button action calls the parent custom method.
(self.parentViewController as? parentVC)?.parentCustomFunc()
which call container2 custom method.
func parentCustomFunc(){
self.container2.customFunc()
}
I read a lot but yet to understand how to apply the use of delegate in this case.
here is my segue block as recorded in parentVC.swift
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let container1VC = segue.destinationViewController as? Cont_1 {
self.container1 = container1VC
} else if let topVC = segue.destinationViewController as? TopVC {
self.container2 = container2VC
}
}
Which of the containers should implement the protocol?
and which of them holds a var to it? How do I get the prepareForSegue to use the delegate?
Thanks