Essential Developer

View Original

Composing View Controllers pt.3: Lifecycle Observers in Swift

Watch on YouTube

In this video, you'll learn how to create your own Swift View Controller Lifecycle Observers. Those observers are very useful when composing and creating reusable view controllers. For example:

controller.onViewDidAppear(run: ItemsAnalytics.reportPageView)

The solution is based on the UIViewController Containers API so there's no need for external frameworks, swizzling or subclassing!

You can find the source code on GitHub.

Learn more about Implementing a Container View Controller from Apple Docs

Subscribe now to our Youtube channel and catch free new episodes every week.