viewDidLoad()
Important: viewDidLoad( ) only gets called ONCE, when the view is created.
viewWillAppear()
Called right after viewDidLoad()
This is called just before the view actually shows up on the screen.
The user is not yet able to see anything, but it is, however, a good time point to be able to hide or show certain UI components.
ex. hiding the navigation bar
The user is not yet able to detect any changes in the view.
viewDidAppear()
viewWillDisappear()
User may tap into this method when the user might navigate back or if they somehow dismissed the current ViewController.
Here, we write some code to prepare for ViewController dismissals.
ex. stopping animations
viewDidDisappear()
→ Important: Just because the view has disappeared, it doesn't mean that it has been deallocated or deleted from the memory of the phone.
→ viewDidDisappear literally means that the user can't see it.
→ The above code doesn't work.
→ At the time we are trying to set label.text, the label of the second VC is still not created (=nil).
Remember we said that a ViewController's IBOutlet, IBActions all get connected up when viewDidLoad( ) is called.
→ But since the label of the secondVC appears to be nil, we can infer that the time when prepare( ) is called is before the viewDidLoad( ) of the secondVC is called.