Last active
October 7, 2024 19:03
-
-
Save eldaroid/14f440081695cc47a64b65aafaea3781 to your computer and use it in GitHub Desktop.
RU: Исследуем жизненный цикл iOS Scene (методы SceneDelegate). EN: Exploring the iOS Scene lifecycle (SceneDelegate methods)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class SceneDelegate: UIResponder, UIWindowSceneDelegate { | |
var window: UIWindow? | |
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | |
guard let windowScene = (scene as? UIWindowScene) else { return } | |
// Настройка окна приложения | |
window = UIWindow(windowScene: windowScene) | |
let initialViewController = ViewController() | |
window?.rootViewController = initialViewController | |
window?.makeKeyAndVisible() | |
} | |
// MARK: - SceneDelegate Lifecycle | |
func sceneDidDisconnect(_ scene: UIScene) { | |
Logger.shared.log("😍 - 0) sceneDidDisconnect") | |
} | |
func sceneDidBecomeActive(_ scene: UIScene) { | |
Logger.shared.log("😍 - 3) applicationDidBecomeActive") | |
} | |
func sceneWillResignActive(_ scene: UIScene) { | |
Logger.shared.log("😍 - 4) applicationWillResignActive") | |
} | |
func sceneDidEnterBackground(_ scene: UIScene) { | |
Logger.shared.log("😍 - 5) applicationDidEnterBackground") | |
} | |
func sceneWillEnterForeground(_ scene: UIScene) { | |
Logger.shared.log("😍 - 6) applicationWillEnterForeground") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Наглядная визуализация методов жизненного цикла SceneDelegate:
Сценарии вызовов каждого метода: