When we are creating segues through the use of Storyboard we generally have a similar pattern.

We can use a constant to make the code a little better.

This is better but we can use the power of extensions to make it better and more concrete.

SegueHandler protocol is implemented by all the view controllers who are interested in taking part in the segue. Now, the view controller can conform to the segue and provide the SegueIdentifier definition as shown below:

The above technique allows the view controller to be more explicit about the use of segues and the enum defines all the possible segues that can originate from the view controller.

If you like this post then you might be interested in checking out my course “A Complete Guide to Lean Controllers in iOS”. The course covers many useful architecture patterns to build better iOS applications. Receive a 74% discount, click on the following link:


  • The above technique was demonstrated in one of the WWDC sessions.

iOS Developer, speaker and educator. Top Udemy and LinkedIn instructor. Lead instructor at DigitalCrafts. https://www.udemy.com/user/mohammad-azam-2/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store