Perform Segue before view is presented

I am going from VC1 to VC2 and once VC2 is loaded, it goes to VC3 via perfomeSegue.
I need VC3 already presented on VC2 before I go to VC2.
Basically I need to go from VC1 to VC3 but I dont want to see VC2. I need already presented behind VC2 (user should not see VC2). To the user it goes from VC1 to VC3
Thanks

Replies

Do you ever show VC2 ?

If not, why do you need passing through it ? To initialize some values ? To load some data ?

If that's it, I think you have the best design.
The code you have in VC2 should be in a model and called directly from VC3.

However, if you really need to do so,
  • don't segue from VC1 to VC2

  • but instantiate VC2

  • then call perform segue.

Code Block
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc2 = storyboard.instantiateViewController(withIdentifier: "ViewController2") as! ViewController2
vc2.loadViewIfNeeded()


See details here:
https://stackoverflow.com/questions/25745854/how-to-initiate-a-viewcontroller-without-presenting-it