This video is a generic look at the typical life cycle of a smartphone app, starting with launching an app through its termination.
- [Presenter] Apps have a well-defined life cycle which encompasses the events of being started, running, and being destroyed. The good news is that for the most part, the OS calls the code you supply for each life cycle event automatically, based on what's happening with your app at any given time. Users generally start an app by touching an icon on a home screen. This can also be the result of a user tapping a resource that is handled by another app, such as touching a link in an email. After the app is started, it is initialized.
This step can include things like displaying a splash screen or passing parameters to the app. Here is where you provide data required by the app and initialize any resources. These can include network and database connections, web resources, and more. Once an app is started and initialized, it moves to the foreground. As in every GUI application, an event loop is executed, where events are initiated by the user or the OS and code is called to handle the events involved in the app's functioning.
The more intuitively you handle events, the more satisfying the user experience will be. Your app can be sent to the background in a few ways. Phone calls have priority over all apps. If a call comes in, your app will be moved to the background until the user interacts with the phone app. The user may also choose to move on to something else and start another app. A text message may come in, for example, and the user may respond to the incoming notification. When your app is sent to the background, you may want to save state, that way should the user come back to the app, they won't need to start from scratch.
The user can choose to terminate your app at any time. In addition, the system may terminate any app in the background to free up resources for the app currently in the foreground. Here is where you should release any resources your app has created, such as network or database connections. You should also save any data to a permanent store.
- iOS platform architecture
- Generic smartphone app life cycle
- iOS app life cycle
- Object-oriented programming (OOP) and Swift
- Inheritance vs. delegation
- Getting started with Xcode
- Xcode vs. Android Studio
- Creating a simple Swift app