The Underrated Child
In previous parts we have learned about application and viewcontroller lifecycle and their states and methods. Before we jump to using some architectural patterns, let’s stick to basic MVC and learn to use child viewcontroller. Child viewcontroller is the way to embed one view controller inside another. They are really good tools to helps us to separate some complex part of the application. In my personal opinion they are really undervalued. Because of the hype and social media exposure of some architectural patterns like MVP, MVVM, VIPER, CleanSwift (CleanVIP)etc., somehow child viewcontroller is suppressed. Don’t get me wrong this architectural patterns are really good and I’m using them myself. Just sometimes they are not necessary to resolve certain types of problems and developers tend to over-engineer.


Below is example code that is built on examples from previous articles. It is a simplified version so it is easier to understand.
More detailed Screen Break Down with use of Child ViewController can be found on this link.
🟢🟢- Logs with 2 green emoji is regular viewcontroller, it represent the child viewcontroller methods.
Important property of UIViewController
is var children: [UIViewController]
it shows an array of view controllers that are children of the current view controller.

Outro
Now we know how to decompose complex screens from as many Child ViewControllers as we need.
In this series we have learnt a pretty wide set of tools to create nice and structured code.
If you had no chance to read article about project organisation bellow is the link. It contains an example of one breakdown of the screen using child viewcontrollers with Visual decomposition technique.
If you got to this point, thanks for reading. 🙂 If you like the content please 👏, share, subscribe, but a coffee it means to me. If you have some suggestions or questions please feel free to comment.