SceneDelegate.swift 965 Bytes
Newer Older
asahiocean's avatar
1  
asahiocean committed
1
2
import UIKit

asahiocean's avatar
2    
asahiocean committed
3
@available(iOS 13.0, *)
asahiocean's avatar
1  
asahiocean committed
4
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
asahiocean's avatar
2    
asahiocean committed
5
6
7
    
    internal var window: UIWindow?
    
asahiocean's avatar
1  
asahiocean committed
8
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
asahiocean's avatar
2    
asahiocean committed
9
10
11
12
        guard let windowScene = (scene as? UIWindowScene) else { fatalError("UIScene nil") }
        switch UIApplication.shared.delegate as? AppDelegate {
        case nil:
            window = UIWindow(windowScene: windowScene)
asahiocean's avatar
asahiocean committed
13
            Self.defaultViewController(for: window)
asahiocean's avatar
2    
asahiocean committed
14
15
16
17
        case let delegate:
            delegate?.window?.windowScene = windowScene
            self.window = delegate?.window
        }
asahiocean's avatar
1  
asahiocean committed
18
    }
asahiocean's avatar
2    
asahiocean committed
19
20
21
22
23
    
    func sceneDidDisconnect(_ scene: UIScene) { }
    func sceneDidBecomeActive(_ scene: UIScene) { }
    func sceneWillResignActive(_ scene: UIScene) { }
    func sceneWillEnterForeground(_ scene: UIScene) { }
asahiocean's avatar
asahiocean committed
24
    func sceneDidEnterBackground(_ scene: UIScene) {}
asahiocean's avatar
1  
asahiocean committed
25
}