iOS Dev 3: Application Lifecycle with illustrations

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi guys my name is Emanuel welcome to the third video of this tutorial series today I'm gonna be teaching you about the iOS application life cycle I've been asked this question a couple of times in iOS interviews so I believe in something worth knowing at every point in time your application is in one of five states the first is in not running state and as it sounds it means that your application is not running it's not executing any code it's not even in memory now whatever you click on your application it goes directly to the inactive state which is where your application is running in foreground but it does not receive any events now from here it goes into your active state which is what we are aware of you can actually interact with your application here you can click on buttons move to different pages so basically it's executing code and it's receiving events now imagine a scenario where from our foreground we receive a phone call so what happens is your application goes directly into the inactive state still in the foreground and the moment you're done with the call your application returns to the active State now we've been on Facebook for quite a while and I feel like I want to play some game whenever I click on my home button the application goes directly to the inactive state and then falls into our background in our background the application still is executing code and depending on the kind of code is executing it can remain in the background for quite a while so imagine that we are actually playing music and in background the music is still playing so the application is going to remain in this stage for quite a while but if we aren't doing anything in the background after some time your application is going to go directly to the suspended State at this point your application is not executing any code is just in memory if for any reason or the other your system is to free up some space for other applications that are running in foreground or background your application will probably be moved to the not running States ok but while in the suspended state it's possible for us to return to our foreground if we click on the application again it's going to go from the suspended state back to the background then to the inactive state and then active again now also situations where our applications go directly from our not running state to the background state and back so imagine that we schedule a background fetch for every one hour so it's possible for our application to be indeed not running State and whenever it gets to the one hour mark it's going to trigger a fetch to our API or whatever and then run in the background when it's done it returns to the not running state so yeah that's a scenario in order to improve user experience or even the performance of the application we might want to know or be informed whenever the application switches between states now thankfully it's possible because iOS actually provides us with a couple of protocols that have been triggered whenever the application changes States and we're going to discuss that shortly but before then if you haven't subscribed to this channel please just take a second to click on the subscribe button and then turn on notification great so first we have we'll finish launching with options and at this point the launch process has begun but the state has Nia been restored we also have is correspondent did finish launching with options where the state has been restored but the UI has not yet been presented to the user now in either of these methods we could decide to perform things like configurations or initializations for example if you wanted to set up push notifications we could do that here next we have seen will enter foreground and this method is actually executed just before as sane transitions from the background to the foreground and one thing to note is that this method is executed whether the scene is newly created or is resuming from the background right so it's executed either way next we have our scene did become active which is executed when our scene becomes active and things we'd like to do here is like start tasks that we have not started or probably resume tasks that were suspended due to enter in the background now let's move on to our termination flow so as you can see first we have the scene wheel resign active this method is actually executed just before the scene transitions from being active to inactive this usually occurs when there is slight interruption in the application so for example if we receive a phone call this method is gonna be triggered okay next we have seen did enter background and this method is executed when the application goes into the background state alright and usually at this point what we'd want to do is save data or free up shared resources so we just want to make sure that whenever we come back to the application we have everything we need to give good user experience and finally we have application will terminate and this method is executed just before our application goes to rest and that's basically it there's a whole lot more delegates that are available for us so as we continue down the line I'm sure we're gonna uncover some of the delegates that we're going to need but for the meantime these should do okay now if you have questions or concerns please leave them in the comment section if you liked the video please give a thumbs up and don't forget to subscribe turn on the notification battle as well see you guys in the next video
Info
Channel: Emmanuel Okwara
Views: 1,712
Rating: undefined out of 5
Keywords: iOSAppLifeCycle, iosdevelopment, iOS
Id: -TSNFZ2wKk4
Channel Id: undefined
Length: 6min 1sec (361 seconds)
Published: Sun May 03 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.