• Feed
  • Explore
  • Ranking
/
/
    📱 iOS

    [iOS] 앱의 실행 순서인 생명 주기(Life Cycle)의 이해

    ios
    지
    지성
    2025.02.12
    ·
    2 min read

    iOS 앱의 생명 주기 개요

    iOS 앱은 사용자의 동작과 시스템 이벤트에 따라 여러 상태를 거친다.

    이 과정에서 앱이 실행되고 종료되는 과정이 결정된다.

    UIApplication의 상태 변화

    앱의 상태 변화는 다음과 같이 이루어진다.

    1. Not Running: 앱이 실행되지 않은 상태

    2. Inactive: 앱이 실행 중이지만 사용자 입력을 받지 않는 상태

    3. Active: 앱이 실행 중이며 사용자 입력을 받는 상태

    4. Background: 앱이 백그라운드에서 실행되는 상태

    5. Suspended: 앱이 메모리에 있지만 실행되지 않는 상태

    AppDelegate와 SceneDelegate

    • AppDelegate: 앱의 전역적인 이벤트를 처리하는 역할

    • SceneDelegate: 멀티 윈도우 지원을 위한 장치별 UI 상태 관리

    생명 주기 관련 메서드

    class AppDelegate: UIResponder, UIApplicationDelegate {
        func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
            print("앱이 실행됨")
            return true
        }
        
        func applicationDidEnterBackground(_ application: UIApplication) {
            print("앱이 백그라운드로 이동")
        }
        
        func applicationWillTerminate(_ application: UIApplication) {
            print("앱이 종료됨")
        }
    }






    - 컬렉션 아티클