Codementor Events

Leverage Storyboard References

Published May 24, 2019Last updated May 27, 2019
Leverage Storyboard References

Storyboards have some issues, and they are not small

If you have ever used Storyboards in your Apps you should be aware of two big drawbacks they have:
1- It's hard, sometimes pretty much impossible, to use them on projects with multiple developers. If two people make small changes on totally unrelated views the merge can be a nightmare.
2- They tend to become massive and slow to load when you start having more than a few views. On a 20-30 views project they start to look like some kind of Spaghetti monster.

Those drawbacks have made a lot of people wary of storyboards, if not even totally forbid their team to use them. I was one of them.

The solution: Storyboard References

Storyboard References totally changed my mind about using Storyboard in a project, no matter the size of the project. Adding Storyboards references to a Storyboard is most of the time as easy as one click. It allows to have a separate Storyboard for each user flow withouth having to handle it somewhere in your code.

How to

Storyboard Monster.png
One of the best places to start using Storyboard References is within an app which has a tab bar. Tabs should already be fairly isolated from each other.
To start the refactoring you need to select every Controlller that is to be moved into a new Storyboard.
Refactor Selection.png
Once they are all selected you have to go to the menu > Editor > Refactor to Storyboard…
Rectactor  Storyboard Menu.png
A prompt will then ask you to name the new Storyboard. In our example we called it Settings.storyboard.
Once you click Save you'll see the newly created Storyboard, with only the selected Controllers.
Isolated Settings.png
Repeat for every Tab and you should have a result looking like this :
Refactored Storyboard with References.png

Conclusion

If you are already using Storyboards in your projects there is absolutely no reason to refrain from using Storyboard References right away. They make everything way smoother with Storyboards.
If you are not using Storyboards at all do Storyboards References make you rethink your position?

Discover and read more posts from Antonio Silva
get started