iOS View Controller Lifecycle

View Controller Lifecycle:

Lifecycle is an event that has several steps from the point of creation to deletion.

It is a sequence of methods as you progress.

init(coder: ):-
Gets called only once when the view is being created in the storyboard.

loadView();
when we instantiate a view controller programmatically we need to override this method.
Called only once.
When we work with creating a view in storyboard. LoadView method in the UIViewcontroller is called automatically to load the Interface files to the screen along with all the outlets hooked up.

viewDidLoad():
This method gets called once the view is created.
It's called only once.
Good place to start some background activity like making network calls that happen only once.

viewWillAppear():
This gets called called several times, whenever view appears on screen.
Good place to update the ui with data that has changed whenever the view is not on screen

viewDidAppear():
This method gets called once the view appears on the screen.
God place to start some animations. or start collecting data with network calls or load data from coredata and present it to the user. or start requesting data from the server.

didReceviedMemoryWarning():
viewController receives all the memory warnings because iOS doesn't handle the memory deallocation for us.

viewWillDissappear():
whenever the ui is transitioning from view to another view or the original view is getting removed from the screen this method gets called.

viewDidDisappear():
This method gets called when the view is removed from the screen.
Good place to stop activities thats we dont need like a network call or stopping animations.


Comments

Popular posts from this blog

A movie Written by David Seidler and directed by Tom Hooper

attitude..