Skip to content

Latest commit

 

History

History
29 lines (21 loc) · 1.09 KB

readme.md

File metadata and controls

29 lines (21 loc) · 1.09 KB

View Controller Lifecycle Behaviors

This is a collection of handy View Controller Lifecycle Behaviors, useful for formalizing reusable bits of common lifecycle-dependent functionality.

Included Behaviors

Usage

Behaviors are implemented by consuming ViewControllers simply by leveraging the category method addBehaviors(_ behaviors: [ViewControllerLifecycleBehavior] in viewDidLoad:

override func viewDidLoad() {
    super.viewDidLoad()
    let behavior1 = MyBehavior()
    let behavior2 = AnotherBehavior()
    addBehaviors([behavior1, behavior2])
}

Default Behaviors

Default behaviors are behaviors that are automatically injected into all view controllers using method swizzling. This may be convenient for functionality akin to analytics screen tagging, for instance. Default behaviors are injected using:

let behavior = MyBehavior()
DefaultBehaviors(behaviors: [behavior]).inject()