SceneDelegate.swift (2835B)
1 // 2 // SceneDelegate.swift 3 // captainsLog 4 // 5 // Created by Benjamin Welner on 10/16/19. 6 // Copyright © 2019 FIGBERT Industries. All rights reserved. 7 // 8 9 import UIKit 10 import SwiftUI 11 12 class SceneDelegate: UIResponder, UIWindowSceneDelegate { 13 14 var window: UIWindow? 15 16 17 func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 18 // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 19 // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 20 // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 21 22 // Create the SwiftUI view that provides the window contents. 23 let contentView = ContentView(audioRecorder: AudioRecorder()) 24 25 // Use a UIHostingController as window root view controller. 26 if let windowScene = scene as? UIWindowScene { 27 let window = UIWindow(windowScene: windowScene) 28 window.rootViewController = UIHostingController(rootView: contentView.environmentObject(GlobalVars())) 29 self.window = window 30 window.makeKeyAndVisible() 31 } 32 } 33 34 func sceneDidDisconnect(_ scene: UIScene) { 35 // Called as the scene is being released by the system. 36 // This occurs shortly after the scene enters the background, or when its session is discarded. 37 // Release any resources associated with this scene that can be re-created the next time the scene connects. 38 // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). 39 } 40 41 func sceneDidBecomeActive(_ scene: UIScene) { 42 // Called when the scene has moved from an inactive state to an active state. 43 // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 44 } 45 46 func sceneWillResignActive(_ scene: UIScene) { 47 // Called when the scene will move from an active state to an inactive state. 48 // This may occur due to temporary interruptions (ex. an incoming phone call). 49 } 50 51 func sceneWillEnterForeground(_ scene: UIScene) { 52 // Called as the scene transitions from the background to the foreground. 53 // Use this method to undo the changes made on entering the background. 54 } 55 56 func sceneDidEnterBackground(_ scene: UIScene) { 57 // Called as the scene transitions from the foreground to the background. 58 // Use this method to save data, release shared resources, and store enough scene-specific state information 59 // to restore the scene back to its current state. 60 } 61 62 63 } 64