0

I have a viewController with containerView andUIPageViewController.

I'm calling editingProfile method but it won't pass into parentNewCarRequestVC. But once I make an action it passes into parentNewCarRequestVC. So please how I can initialise the parentView once the screen start.

I'm so sorry if I didn't explain my issue well.

override func viewDidAppear(animated: Bool) {
    editingProfile()
}

func editingProfile(){
    if let parentVC = self.parentViewController as? UIPageViewController{
        if let parentNewCarRequestVC = parentVC.parentViewController as? NewCarRequestViewController{

            print("DONE")
        }
    }
}
Nilesh
  • 701
  • 5
  • 14
Luai Kalkatawi
  • 1,492
  • 5
  • 25
  • 51

2 Answers2

0

Your assumptions must be wrong. Do this:

func editingProfile(){

   print(self.parentViewController)
   print(self.parentViewController.parentViewController)

    if let parentVC = self.parentViewController as? UIPageViewController{
        if let parentNewCarRequestVC = parentVC.parentViewController as? NewCarRequestViewController{

        print("DONE")
    }
}

}

Show us the debugger output for both prints.

Earl Grey
  • 7,426
  • 6
  • 39
  • 59
0

call ur method id viewDidLoad. If u want to call in viewWillAppear then initialise in viewDidLoad and

parentNewCarRequestVC = parentVC.parentViewController as? NewCarRequestViewController in viewWillAppear.

vikash1307
  • 272
  • 2
  • 12