29 Nov 2019
iOS - application lifecycle
Five States of Application Lifecycles
- Not Running
- Inactive
- Active
- Background
- Suspended
- App can only run code when in foreground (active or inactive) or background (background)
ViewController Lifecycle
```
viewDidLoad()
viewWillAppear()
viewDidAppear()
viewWillDisappear()
viewDidDisappear()
```
viewDidLoad
- called when the view controller is created and loaded in memory. Usually called only onceviewWillAppear
- called right before the content view is presented onscreen and before the content view is added to the view hierarchyviewDidAppear
- called when the content view is added to the view hierarchy. Use this method to trigger any events that need to occur as soon as the view is presented on screen, such as fetching and loading data or showing animationviewWillDisappear
- called right before the content view is removed from the view hierarchy. Use this method to trigger any clean up events, such as resigning first responderviewDidDisappear
- called when the content view is removed from the view hierarchy
Til next time,
lovelejess
at 09:32