iOS/Swift [Swift] UISceneDelegate - UISceneDelegate Scene 내에서 발생하는 수명 주기(Life Cycle) 이벤트에 응답하는 데 사용하는 핵심 방법 UISceneDelegate | Apple Developer Documentation The core methods you use to respond to life-cycle events occurring within a scene. developer.apple.com Connecting and disconnecting the scene scene(_:willConnectTo:options:) : Delegate에 앱의 Scene을 추가하는 것을 알림 func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let windowScene = (scene as? UIWindowScene) else { return } window = UIWindow(windowScene: windowScene) window?.backgroundColor = .systemBackground window?.rootViewController = UIViewController() window?.tintColor = .label window?.makeKeyAndVisible() } scene(_:willConnectTo:options:) | Apple Developer Documentation Tells the delegate about the addition of a scene to the app. developer.apple.com sceneDidDisconnect(_:) : Delegate에 UIKit에서 앱의 Scene을 제거했다고 알림 sceneDidDisconnect(_:) | Apple Developer Documentation Tells the delegate that UIKit removed a scene from your app. developer.apple.com UIScene.ConnectionOptions : UIKit에서 Scene을 생성한 이유에 대한 정보를 포함한 데이터 객체 (Class) UIScene.ConnectionOptions | Apple Developer Documentation A data object containing information about the reasons why UIKit created the scene. developer.apple.com Transitioning to the foreground (foreground로 전환 중) scenewillEnterForeground(_:) Scene이 foreground에서 실행되기 시작하고 사용자에게 표시될 것을 Delegate에 알림 scenewillEnterForeground sceneWillEnterForeground(_:) | Apple Developer Documentation Tells the delegate that the scene is about to begin running in the foreground and become visible to the user. developer.apple.com sceneDidBecomeActive(_:) Scene이 활성화되어 이제 사용자 event에 응답하고 있음을 Delegate에 알림 (scenewillEnterForeground 이후) sceneDidBecomeActive(_:) | Apple Developer Documentation Tells the delegate that the scene became active and is now responding to user events. developer.apple.com Transitioning to the background (background로 전환 중) sceneWillResignActive(_:) Scene이 활성 상태를 종료하고 사용자 event에 대한 응답을 중지한다고 Delegate에 알림 scenewillResignActive sceneWillResignActive(_:) | Apple Developer Documentation Tells the delegate that the scene is about to resign the active state and stop responding to user events. developer.apple.com sceneDidEnterBackground(_:) Scene이 background에서 실행 중이며, 더 이상 화면에 표시되지 않음을 Delegate에 알림 (scenewillResignActive 이후 실행) sceneDidEnterBackground sceneDidEnterBackground(_:) | Apple Developer Documentation Tells the delegate that the scene is running in the background and is no longer onscreen. developer.apple.com Opening URLs scene(_:openURLContexts:)Delegate에 하나 이상의 URL을 열도록 요청 scene(_:openURLContexts:) | Apple Developer Documentation Asks the delegate to open one or more URLs. developer.apple.com ※ 다른 앱에서 데이터 가져오기 1. willConnectTo 에서 delegate 선언 class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? static weak var shared: SceneDelegate? // 선언 func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { if let sceneDelegate = scene.delegate as? SceneDelegate { SceneDelegate.shared = sceneDelegate } } } 2. openURLContext()에서 가져오기 func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { // 결과값 if let url = URLContexts.first?.url{ } } 728x90 공유하기 게시글 관리 구독하기Joey의 블로그 'iOS > Swift' 카테고리의 다른 글 [Swift] RelativeDateTimeFormatter(상대시간) (0) 2023.11.20 [Swift] 공식문서 파헤치기 (Array, Set, Dictionary) (0) 2023.11.11 [Swift] frame vs bounds (1) 2023.10.28 [Swift] BackgroundTasks (0) 2023.09.03 [Swift] Dynamic Library vs Static Library (0) 2023.08.21 Contents 당신이 좋아할만한 콘텐츠 [Swift] RelativeDateTimeFormatter(상대시간) 2023.11.20 [Swift] 공식문서 파헤치기 (Array, Set, Dictionary) 2023.11.11 [Swift] frame vs bounds 2023.10.28 [Swift] BackgroundTasks 2023.09.03 댓글 0 + 이전 댓글 더보기