view did load, did love, did loathe.
Quick notes on the iOS View Life cycle based on the Apple docs
viewDidLoad()
- 📞 called only once !
- 📞 called when content view is created
- 👀 but it is not necessary that the content view is created when the view controller is instantiated for the first time
- 🥱 content view is lazily created!
- 🧰 USE CASE: additional setup
- 📋 Storyboard — outlets guaranteed to have valid values
viewWillAppear()
- 📞 called when content view is about to be added to the view hierarchy
- ⚠️ does NOT guarantee that the content view will be visible
- view could be hidden or obscured by other views
- 🧰 USE CASE: any operation before the content view is presented onscreen
viewDidAppear()
- 📞 called right after the content view is added to the view hierarchy
- ⚠️ does NOT guarantee that the content view will be visible
- view could be hidden or obscured by other views
- 🧰 USE CASE: any operation that needs to take place as soon as the view is presented onscreen
- eg) fetching data
- eg) showing an animation
viewWillDisappear()
- 📞 called when content view is about to be removed from the view hierarchy
- ⚠️ wont be called just because the content view has been obscured or hidden
- 🧰 USE CASE: clean up tasks 🧼
- eg) committing changes
- eg) resigning first responder status
viewDidDisappear()
- 📞 called right after the content view is removed from the view hierarchy
- ⚠️ wont be called just because the content view has been obscured or hidden
- 🧰 USE CASE: additional tear down activities ✂️