As a beginner, I used to perform segues in ViewControllers. Moreover, Apple encourages such approach, because UIViewController has methods performSegue and prepareForSegue.
But learning VIPER, I read that Router is responsible for transitions between scenes. And the second thing is that according to VIPER flowcharts like this:

Router mustn't be tied with View.
I absolutely don't want to refuse from using segues, because it is extremely powerful and allows me to easily transfer data between ViewControllers.
So, how should I perform transitions between ViewControllers?
In pure VIPER all transitions should be performed in Router. So you would not be able to use segues if you'll choose to implement VIPER
Personally I prefer using Storyboard ID rather than segues.
For example :
1. Put a relevant storyboard ID for your view.
image link.
2. Then you can access that view like :
let loginVC = UIStoryboard(name: "Main", bundle:nil).instantiateViewController(withIdentifier: "Login")
3. You can pass data with it like: loginVC.type = 0
4. You can access it whenever you want like:
navigationController?.pushViewController(loginVC, animated: true)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With