
1. 2 app anatomy and life cycle — develop in swift data collections 重點整理
- Select a language for the TTS:
- UK English Female
- UK English Male
- US English Female
- US English Male
- Australian Female
- Australian Male
- Language selected: (auto detect) - EN
Play all audios:

LAB — APP EVENT COUNT 說明: * 重點 FUNCTION * AppDelegate application(_:didFinishLaunchingWithOptions:) application(_:configurationForConnecting:options:) * SceneDelegate
scene(_:willConnectTo:options:) sceneDidBecomeActive(_:) sceneWillResignActive(_:), sceneWillEnterForeground(_:) sceneDidEnterBackground(_:) VIEWCONTROLLER 宣告 PROPERTY APPDELEGATE 方便存取
appDelegate。 var appDelegate = UIApplication.shared.delegate as! AppDelegate 3. SCENEDELEGATE 宣告 PROPERTY VIEWCONTROLLER 方便存取 viewController。從 window?.rootViewController 取得第一個畫面的 view
controller。 class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? var viewController: ViewController? func scene(_ scene: UIScene, willConnectTo session:
UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { viewController = window?.rootViewController as? ViewController 4. 在 SCENEDIDBECOMEACTIVE 更新 CONTROLLER 畫面 func
sceneDidBecomeActive(_ scene: UIScene) { viewController?.didBecomeActiveCount += 1 viewController?.updateView() } 參考連結 * APP AND ENVIRONMENT * MANAGING YOUR APP’S LIFE CYCLE