From 5bc8adfd431780b67e6dd2a26c4af183703a1bdc Mon Sep 17 00:00:00 2001 From: CMK Date: Wed, 24 Feb 2021 17:23:30 +0800 Subject: [PATCH] fix: re-entry crash issue --- Mastodon/Scene/Welcome/WelcomeViewController.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Mastodon/Scene/Welcome/WelcomeViewController.swift b/Mastodon/Scene/Welcome/WelcomeViewController.swift index 99aa89f92..3c95fa4f4 100644 --- a/Mastodon/Scene/Welcome/WelcomeViewController.swift +++ b/Mastodon/Scene/Welcome/WelcomeViewController.swift @@ -14,7 +14,12 @@ final class WelcomeViewController: UIViewController, NeedsDependency { weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } #if DEBUG - let authenticationViewController = AuthenticationViewController() + lazy var authenticationViewController: AuthenticationViewController = { + let authenticationViewController = AuthenticationViewController() + authenticationViewController.context = context + authenticationViewController.coordinator = coordinator + return authenticationViewController + }() #endif let logoImageView: UIImageView = { @@ -105,8 +110,6 @@ extension WelcomeViewController { os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) #if DEBUG - authenticationViewController.context = context - authenticationViewController.coordinator = coordinator authenticationViewController.viewModel = AuthenticationViewModel(context: context, coordinator: coordinator, isAuthenticationExist: true) authenticationViewController.viewModel.domain.value = "pawoo.net" let _ = authenticationViewController.view // trigger view load