View controllers play a crucial role for designing most iPhone applications.Today, I am going to explain only the UIViewController Life Cycle.The UIViewController class is the base class that establishes communication between model and View in iOS MVC design
pattern.
While we are loading a view into the screen, some events will be fired as explained here.
Read:
How to use NSURLConnection in iOS ?
Basic iOS interview Questions And Answers
Top 5 Frequently Asked iOS Interview Questions And Answers.
Top Interview Questions And Answers in Objective C
Most Important iPhone interview Questions and Answers
loadView:
UIViewController's code will call the loadView method to create the view for the view controller. The code of UIKit will call the loadView method if and when it actually needs to present that controller's view hierarchy on screen.As per the apple's documentation, no need to call these methods directly.You can just ignore these method ,if you are using storyboard. Its implementation in UIViewController loads the interface from the interface file and connects all the IBOutlets and IBActions for you.
ViewDidLoad:
This is one of the the most important events in view Controller's life cycle .UIViewController calls this method when the view has been created and loaded into memory along with all outlets.This method is called automatically when the view is already created programmatically or loaded from XIB.
This method is called just before the view added to the display hierarchy. This method to update the user interface with data that might have changed while the view controller was not on the screen.
Note:
This event can be called many times for the same instance of a view controller
ViewDidAppear():
This method is called when the view is added to the screen.Usually,starting animations in the user interface,a sound, or to start collecting data from the network can be implemented here.
Read:
How to get 1024x1024 icon from iTunes Connect ?
iOS - How to implement Local Notifications using Objective C
ViewWillDisappear():
This method is called prior to removing the view from the display hierarchy. If you override this method, you must always call base.ViewWillDisappear(). It's a good idea to undo anything that you implemented in ViewWillAppear() or ViewDidAppear().
ViewDidDisappear():
This method is called after the view is removed from the display hierarchy.
DidReceieveMemoryWarning().
This method can also be called when the view has already disappeared from the display hierarchy, which would normally occur if you have left large objects in memory and the system needs to dispose them to make room for other processes. If you override this method, you must always.