All Projects → essentialdevelopercom → view-controller-lifecycle-observers

essentialdevelopercom / view-controller-lifecycle-observers

Licence: MIT license
Useful UIViewController extension for composing/creating reusable view controllers – no swizzling or subclassing needed!

Programming Languages

swift
15916 projects

UIViewController Lifecycle Observers

Build Status

Useful UIViewController extension for composing/creating reusable view controllers – no swizzling or subclassing needed! Learn more at: https://www.essentialdeveloper.com/articles/composing-view-controllers-part-3-lifecycle-observers-in-swift

controller.onViewWillAppear {
    print("viewWillAppear was called!")
}

This extension is very useful when composing view controllers with other modules. For example:

let analytics = ItemsAnalytics()
itemsListController.onViewDidAppear(run: analytics.reportListPageView)

You can also stop receiving messages by removing observers:

let service = ItemsService()
let observer = controller.onViewWillAppear(run: service.reloadItems)
observer.remove()
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].