일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Swift
- 생명주기
- vuex
- Interface
- mongoose
- docker
- ReactNative
- collection
- react native
- lifecycle
- CLASS
- enum
- recyclerview
- class component
- ConstraintLayout
- AWS
- list
- MINUS
- Kotlin
- Service
- Filter
- union
- docker-compose
- animation
- elementAt
- Generic
- map
- function
- LiveData
- Foreign Key
- Today
- Total
개발 일기
SceneDelegate 본문
IOS 13이전에는 대부분의 앱은 하나의 윈도우를 가지고 있었습니다.
하지만 IOS 13이후부터는 이제는 window 개념이 scenc 으로 변경이 되었습니다.
그래서 이제는 하나의 앱에서 여러개의 Scene을 가질수가 있습니다.
이제는 UILifeCycle 부분을 다음과 같이 Scene에서 대체할수 있게 되었습니다.
-
scene:willEnterForeground
-
scene:didEnterBackground
-
scene:willResignActive
-
scene:didBecomActive
그리고 이제는 AppDelegate에서 Scene LifeCycle에 대한 부분이 추가가 되었습니다.
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
Scene?
UIKit는 UIWindowScene 객체를 사용하는 앱 UI의 각 인스턴스를 관리합니다.
Scene에는 UI의 하나의 인스턴스를 나타내는 windows와 view controllers가 들어있습니다. 또한 각 scene에 해당하는 UIWindowSceneDelegate 객체를 가지고 있고, 이 객체는 UIKit와 앱 간의 상호 작용을 조정하는 데 사용합니다.
Scene들은 같은 메모리와 앱 프로세스 공간을 공유하면서 서로 동시에 실행됩니다.
결과적으로 하나의 앱은 여러 scene과 scene delegate 객체를 동시에 활성화할 수 있습니다.
(Scenes - Apple Developer Document 참고)UI의 상태를 알 수 있는 UILifeCycle에 대한 역할을 SceneDelegate에서 하고
역할이 분리된 대신 AppDelegate에서 Scene Session을 통해서 scene에 대한 정보를 업데이트 받습니다.
Scene Session?
UISceneSession 객체는 scene의 고유의 런타임 인스턴스를 관리합니다.
사용자가 앱에 새로운 scene을 추가하거나 프로그래밍적으로 scene을 요청하면,
시스템은 그 scene을 추적하는 session 객체를 생성합니다.
그 session에는 고유한 식별자와 scene의 구성 세부사항(configuration details)가 들어있습니다.
UIKit는 session 정보를 그 scene 자체의 life time동안 유지하고 app switcher에서 사용자가 그 scene을 클로징하는 것에 대응하여 그 session을 파괴합니다. session 객체는 직접 생성하지않고 UIKit가 앱의 사용자 인터페이스에 대응하여 생성합니다. 또한 위 3번에서 소개한 두 메소드를 통해서 UIKit에 새로운 scene과 session을 프로그래밍적 방식으로 생성할 수 있습니다.
iOS13부터 AppDelegate가 하는 일?
이제부터는 앱의 상태를 업데이트 하는 (foreground or background) 관련 이벤트를 처리를 하지 않습니다.
따라서 다음과 같은 역할을 진행을 합니다.
1. 앱의 가장 중요한 데이터 구조를 초기화하는 것
2. 앱의 scene을 환경설정(Configuration)하는 것
3. 앱 밖에서 발생한 알림(배터리 부족, 다운로드 완료 등)에 대응하는 것
4. 특정한 scenes, views, view controllers에 한정되지 않고 앱 자체를 타겟하는 이벤트에 대응하는 것.
5. 애플 푸쉬 알림 서브스와 같이 실행시 요구되는 모든 서비스를 등록하는것.
입니다.
'Client > IOS' 카테고리의 다른 글
UIGestureRecognizerDelegate ? (0) | 2020.05.03 |
---|---|
UIPanGestureRecognizer ? (0) | 2020.05.03 |
UISwipeGestureRecognizer ? (0) | 2020.05.01 |
ViewController 생명 주기 ? (0) | 2020.05.01 |
AppDelegate ? (0) | 2020.04.25 |