Interview PrepMidOpen-ended

Explain the iOS app lifecycle.

Explanation & Code

Answer: An iOS app moves through states managed by UIApplicationDelegate (UIKit) or @main + scene lifecycle (SwiftUI/iOS 13+).

States:

  1. Not Running — app hasn't launched or was terminated
  2. Inactive — foreground but not receiving events (e.g. incoming call)
  3. Active — foreground, running normally
  4. Background — executing code off-screen (limited time)
  5. Suspended — in memory but not executing

Key delegate methods (UIKit):

func application(_:didFinishLaunchingWithOptions:)  // setup
func applicationDidBecomeActive(_:)                 // resume
func applicationWillResignActive(_:)                // pause
func applicationDidEnterBackground(_:)              // save state
func applicationWillTerminate(_:)                   // cleanup

Rate your understanding:

Ready to practice more Interview Prep?

Test yourself with our interactive quiz mode or browse all curated questions for this topic.