I have a PageViewcontroller
has 3 child controllers. I want to pass data from first child to Root PageViewController
This is my Root Controller.
I tried :
class RootViewController: UIPageViewController ,UIPageViewControllerDataSource{
var isSelectAnything : Bool = false
func addRightBottom(sendBool : Bool){
self.isSelectAnything = sendBool
print(isSelectAnything) // always return false even I select a cell from my child
}
This is my Child Controller.
class FirstView: UIViewController,UICollectionViewDelegate,UICollectionViewDataSource {
//There is a collectionview and this method works on :
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let sendData = RootViewController()
sendData.addRightBottom(sendBool: true)
}
When I select a cell from collectionview I want to change isSelectAnything
value with true but its always return false.I searched but cant find any solutions.
I tried protocols but Its didnt work again
Change
let sendData = RootViewController()
To
let sendData = parent as! RootViewController