아삭아삭 iOS 개발

[iOS] AppDelegate 와 SceneDelegate 본문

카테고리 없음

[iOS] AppDelegate 와 SceneDelegate

바닐라머스크 2022. 5. 27. 00:14

iOS13부터 기존 AppDelegate의 역할 중 UI의 상태를 알 수 있는 UILifeCycle에 대한 부분을 UISceneDelegate가 담당하게 됨

WWDC2019 영상화면 중 일부

 

AppDelegate란?

: 개발자로 하여금 코딩으로 앱 생명주기 단계별 실행작업들을 정의할 수 있도록 돕는 객체

  • 앱의 중요 데이터 구조를 초기화함
  • 앱의 scene들의 환경을 구성함
  • 앱 외부에서 발생한 알림들에 대응함 (배터리 부족, 다운로드 완료 알림 등)
  • 앱 자체를 타겟으로 한 이벤트들에 대응함
  • 앱의 특정 scenes, views, view controllers에 타겟팅하지 않은 이벤트들에 대응함
  • 앱 실행시 요구되는 모든 서비스들을 등록함 (apple push notification 서비스 등)

AppDelegate.swift


SceneDelegate란?

: 말그대로 scene의 대리자 역할을 수행함

  • 현재 scene에서 다른 scene으로 넘어가거나 해당 시점들을 파악함
    (Foreground ↔ Background)
  • 사용자가 보는 화면에 여러개의 scene이 나타나는 멀티테스킹의 개념이 새롭게 도입되면서,
    기존 AppDelegate의 역할 중 UI의 상태를 알 수 있는 UILifeCycle에 대한 부분을 맡게 됨

SceneDelegate.swift

 

 

■ 참고자료

[1] https://developer.apple.com/documentation/uikit/uiapplicationdelegate

[2] https://lena-chamna.netlify.app/post/appdelegate_and_scenedelegate/

[3] https://developer.apple.com/documentation/uikit/uiscenedelegate

[4] https://developer.apple.com/videos/play/wwdc2019/258