Notice
Recent Posts
Recent Comments
Link
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

Geon

iOS 앱의 생명주기(App Life Cycle)에 대해 설명해주세요. 본문

CS

iOS 앱의 생명주기(App Life Cycle)에 대해 설명해주세요.

jgkim1008 2024. 4. 13. 14:55

  • 앱의 각 상태(Not Running, Inactive, Active, Background, Suspended)에서 할 수 있는 작업은 무엇인가요?
    • Not Running
      • 앱이 아직 실행되지 않았거나, 완전히 종료되어 동작하지 않는 상태
    • Inactive
      • Inactive는 앱이 실행중이지만 사용자로부터 이벤트를 받을수 없는 상태
      • 사용자가 APP을 사용중이였다가, 전화나 문자를 수신했을경우
    • Active
      • 앱이 event를 수신받을수 있는 상태
      • 사용자가 APP을 사용하는 상태
    • BackGround
      • APP이 백그라운드 상태에서 실행중인 상태 이고, 이벤트를 수신할수 있으며 코드를 실행할수 있다.
      • 이상태에서는 짧은 작업을 수행하고 제어권을 OS로 돌려놔야 한다.
    • Suspended
      • APP은 백그라운드에 있지만 코드는 실행되지 않는 상태
      • OS는 메모리가 부족시 해당 APP을 제거하려고 한다.
  • 앱 상태 변화에 따라 호출되는 AppDelegate 메서드들을 나열해주세요.
    • func applicationWillResignActive(UIApplication)
      • Tells the delegate that the app is about to become inactive.
    • func applicationDidEnterBackground(UIApplication)
      • Tells the delegate that the app is now in the background.
    • func applicationWillEnterForeground(UIApplication)
      • Tells the delegate that the app is about to enter the foreground.
    • func applicationWillTerminate(UIApplication)
      • Tells the delegate when the app is about to terminate.
    • class let didBecomeActiveNotification: NSNotification.Name
      • A notification that posts when the app becomes active.
    • class let didEnterBackgroundNotification: NSNotification.Name
      • A notification that posts when the app enters the background.
    • class let willEnterForegroundNotification: NSNotification.Name
      • A notification that posts shortly before an app leaves the background state on its way to becoming the active app.
    • class let willResignActiveNotification: NSNotification.Name
      • A notification that posts when the app is no longer active and loses focus.
    • class let willTerminateNotification: NSNotification.Name
      • A notification that posts when the app is about to terminate.
  • 백그라운드에서 작업을 완료하기 위한 방법들은 무엇이 있나요?
    • XCode -> 타겟 -> Capabilities -> Background Mode
    • BackGroundTask 설정
      • BGAppRefeshTask
        • 가벼운 작업, 단순 API 호출 및 저장, 사용자 기기를 사용하는 시간에도 실행 가능
      • BGProcessingTask
        • DB등 크고 무거운 작업