Application lifecycle
States
- Not running — the process is not started or was terminated by the system/user.
- Inactive — the app is on screen but receives no events: an incoming call, an open Control Center / Notification Center, the app switcher, a system alert (permission prompt). A transitional state.
- Active — normal foreground operation, events are delivered.
- Background — the app is off screen but code still runs: a few seconds to finish work (
beginBackgroundTask), or longer with a declared background mode (audio, location, VoIP,BGTaskScheduler, backgroundURLSession). - Suspended — the app is in memory but runs no code. The transition happens without notification; under memory pressure the system evicts the app, also silently (
applicationWillTerminateis not called).
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep