One of the most fundamental building blocks, when creating apps for iOS or macOS, is the view controller. Sometimes misused, sometimes dreaded, and often misunderstood, this component can be both your best ally and your worst enemy.
We'll go back to the Model-View-Controller (MVC) pattern in this chapter, looking at its origins and philosophy and exploring in the context of UIKit how we can turn this design pattern to our advantage when designing modern apps.
We'll start by refreshing ourselves on the basics of the MVC pattern, what each component should do, and how they fit together. We'll then revisit view controller life cycles, explore some best practices, and learn some decoupling strategies to keep the view controllers as lean as they should be.
In this chapter, we will look at the following:
- The theory behind the pattern...