Thursday, November 21, 2013

iOS App life cycle

Today will see the iOS App life cycle, mainly on
1) The App Launch Cycle
2) The View Controller Life Cycle

1) The App Launch Cycle

Lets see as soon as you tap on any application icon to open any iOS app in your device springboard what will happen,

- As part of the launch cycle, the iOS system creates a process and main thread for 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: https://developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/Art/app_launch_fg_2x.png) 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.

viewDidLoadCalled 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 removed and 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.


 Hope this post is helpful,any comments or suggestions is acceptable.



44 comments:

  1. Awsome Explanation brother..............

    ReplyDelete
  2. Replies
    1. @ravindra Firstly many thanks for liking and following my blog, yep sure I will come up with many more tutorials soon, since I was busy with my daily schedule I was unable to post frequently.
      Thanks :)

      Delete
  3. Nice blogs.
    Videocon and stay in touch with your Contacts, Friends, and Loved ones.
    Seamless Roaming across India. National Roaming is Pre-Activated on Videocon Prepaid Connection with Zero Monthly Rentals.
    Tariff while Roaming anywhere in India.

    ReplyDelete
  4. It’s really amazing that we can record what our visitors do on our site. Thanks for sharing this awesome guide. I’m happy that I came across with your site this article is on point,thanks again and have a great day. Keep update more information..


    iOS Training in Chennai

    ReplyDelete
  5. I am expecting more interesting topics from you. And this was nice content and definitely it will be useful for many people.

    Mobile App Development Company in Chennai
    Android app Development Company in Chennai
    ios app development Company in Chennai

    ReplyDelete
  6. It's interesting that many of the bloggers your tips helped to clarify a few things for me as well as giving.. very specific nice content. And tell people specific ways to live their lives.Sometimes you just have to yell at people and give them a good shake to get your point across.
    Mobile App Development Company
    Android app Development Company
    ios app development Company
    Mobile App Development Companies

    ReplyDelete
  7. Great article,we are providing IOS online training you can check it out

    ReplyDelete
  8. Thanks for posting useful information.You have provided an nice article, Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...Really it was an awesome article...very interesting to read..
    please sharing like this information......
    Android training in chennai
    Ios training in chennai

    ReplyDelete
  9. I am expecting more interesting topics from you. And this was nice content and definitely it will be useful for many people.
    Mobile App Development Company
    Mobile App Development Company
    Mobile app Development Companies

    ReplyDelete

  10. Nice it seems to be good post... It will get readers engagement on the article since readers engagement plays an vital role in every blog.. i am expecting more updated posts from your hands.
    Android App Development Company

    ReplyDelete
  11. great and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one.
    web design Company
    web development Company
    web design Company in chennai
    web development Company in chennai
    web design Company in India
    web development Company in India

    ReplyDelete
  12. it is really amazing...thanks for sharing....provide more useful information...
    Mobile app development company

    ReplyDelete
  13. Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well as giving..
    Fitness SMS
    Salon SMS
    Investor Relation SMS

    ReplyDelete
  14. You have provided an nice article, Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...
    iOS App Development Company

    ReplyDelete
  15. Nice blog..! I really loved reading through this article... Thanks for sharing such an amazing post with us and keep blogging...
    ios app development course

    ReplyDelete
  16. Nice it seems to be good post... It will get readers engagement on the article since readers engagement plays an vital role in every Texting API
    Text message marketing
    Digital Mobile Marketing
    Sms API
    Sms marketing

    ReplyDelete
  17. Hey there, You have done a fantastic job. I’ll definitely digg it and personally suggest to my friends. I am confident they will be benefited from this web site.

    PSD to Wordpress
    wordpress website development

    ReplyDelete
  18. Thanks for posting the useful information to my vision. This is excellent information,.
    mobile application training in hyd

    ReplyDelete
  19. Nice blog and absolutely outstanding. You can do something much better but i still say this perfect.Keep trying for the best. Hire iPhone Developers India

    ReplyDelete
  20. Good article write and good Information share this Article. Android app Development company In India

    ReplyDelete
  21. Nice post. Thanks for sharing and upgrading our information.
    Best iPhone mob app training in Jaipur

    ReplyDelete
  22. Extraordinary and helpful article. Making content consistently is extremely intense. Your focuses are roused me to proceed onward.


    digital marketing

    ReplyDelete
  23. Magnificent design and great utilization of fluctuated media. Truly inside and out data also. Extremely like how you separate the points into a few subsections with their own pages.


    iphone 8 plus case


    ReplyDelete
  24. The article is good.I got some knowledge about iOS.Thanks for sharing this blog.
    iOS Training In Chennai | iOS Training Institute In Chennai

    ReplyDelete
  25. Nice blog. Thanks for sharing such great information.Develop xamarin application Hire xamarin developer , Hire xamarin developer India

    ReplyDelete
  26. The Content was super and useful.Thankyou for posting this blog.I got some knowledge.
    iOS Training In Chennai | iOS Training Institute In Chennai

    ReplyDelete
  27. I liked the way of presention.Its good and Informative.Thank you for posting this article
    iOS Training In Chennai | iOS Training Institute In Chennai

    ReplyDelete
  28. This article gave good information.Thank you for posting this article.
    iOS Training In Chennai | iOS Training Institute In Chennai

    ReplyDelete