View Controller’s life cycle


View Controller call a series of methods before loading all the views and being ready for users to interact with them. The “viewDidLoad” method is invoked first. Inside it we should do any additional setup after loading the view, typically from a nib.

There are other 4 commonly used methods that any iOS developer should know about:

– (void)viewWillAppear:(BOOL)animated
– (void)viewDidAppear:(BOOL)animated
– (void)viewWillDisappear:(BOOL)animated
– (void)viewDidDisappear:(BOOL)animated

“viewWillAppear” is called when the view is about to made visible. Default does nothing.

“viewDidAppear” is called when the view has been fully transitioned onto the screen. Default does nothing.

“viewWillDisappear” is called when the view is dismissed, covered or otherwise hidden. Default does nothing.

“viewDidDisappear” is called after the view was dismissed, covered or otherwise hidden. Default does nothing.

There are situations when we need some specific things to be done, for example to save some data if the user quits the app, and these and some other ones are the places where she to insert that logic in our projects.

Leave a comment