iOS App life cycle

– As part of the launch cycle, the iOS system creates a process and main threadfor your app and calls your app’s main function on that main thread.


– The default main function that comes with your Xcode project promptly hands control over to the UIKit framework, it will initialize your app and prepares it to run.


Below flowchart (diagram from Apple’s developer docs: will show the sequence of events that occurs when an app is launched into the foreground



The main function’s main job is to hand control to the UIKit framework.


2) The View Controller Life Cycle


Now lets see once your app is launched then say your first screen (Root/Home View Controller), how it will load in to the screen in other words the view controller life cycle hierarchy,

If you are creating your UI or View programmatically then the first method which gets called is loadView, followed by viewDidLoad -> viewWillAppear -> viewDidAppear  and while moving to the next screen or view Controller the hierarchy of methods are like viewWillDisappear -> viewDidDisappear -> viewDidUnload  


Note: In iOS 6 and later, viewDidUnload method is deprecated since views are no longer purged under low-memory conditions.


viewDidLoad – Called only once during the initial load of interface builder(.xib) file. Initial set up of view controller can be taken care here.


viewWillAppear – This method gets called just before your view appears or renders on screen every time when you navigate or switch between different views. Suppose if you want to update your view different while switching back and forth based on some requirement for that kind of dynamic changes to the views can be done here.


viewDidAppear – Once your view loads completely on screen this method gets called and here you can handle further UI or functionalities w.r.t your view controller like database call or whatever you want to do after loading your view.


viewWillDisappear – This method is called before the view is actually removedand before any animations are configured. Notifies the view controller that its view is about to be removed from a view hierarchy.


viewDidDisappear – This method notifies the view controller that its view was removed from a view hierarchy, here you can perform additional tasks associated with dismissing or hiding the view.


viewDidUnload – Called when the controller’s view is released from memory. In iOS 6 and later, clearing references to views and other objects in your view controller is unnecessary. In iOS 6 and later, viewDidUnload method is deprecated.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s