Geon
iOS 앱의 생명주기(App Life Cycle)에 대해 설명해주세요. 본문
- 앱의 각 상태(Not Running, Inactive, Active, Background, Suspended)에서 할 수 있는 작업은 무엇인가요?
- Not Running
- 앱이 아직 실행되지 않았거나, 완전히 종료되어 동작하지 않는 상태
- Inactive
- Inactive는 앱이 실행중이지만 사용자로부터 이벤트를 받을수 없는 상태
- 사용자가 APP을 사용중이였다가, 전화나 문자를 수신했을경우
- Active
- 앱이 event를 수신받을수 있는 상태
- 사용자가 APP을 사용하는 상태
- BackGround
- APP이 백그라운드 상태에서 실행중인 상태 이고, 이벤트를 수신할수 있으며 코드를 실행할수 있다.
- 이상태에서는 짧은 작업을 수행하고 제어권을 OS로 돌려놔야 한다.
- Suspended
- APP은 백그라운드에 있지만 코드는 실행되지 않는 상태
- OS는 메모리가 부족시 해당 APP을 제거하려고 한다.
- Not Running
- 앱 상태 변화에 따라 호출되는 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.
- func applicationWillResignActive(UIApplication)
- 백그라운드에서 작업을 완료하기 위한 방법들은 무엇이 있나요?
- XCode -> 타겟 -> Capabilities -> Background Mode
- BackGroundTask 설정
- BGAppRefeshTask
- 가벼운 작업, 단순 API 호출 및 저장, 사용자 기기를 사용하는 시간에도 실행 가능
- BGProcessingTask
- DB등 크고 무거운 작업
- BGAppRefeshTask
'CS' 카테고리의 다른 글
Swift에서 옵셔널이란 무엇이며, 언제 사용해야 하나요? (0) | 2024.04.13 |
---|---|
컴퓨터 구조와 관련하여 CPU, RAM, 저장장치의 역할과 상호 작용에 대해 설명해주세요. (0) | 2024.04.12 |