Skip to content

Instantly share code, notes, and snippets.

@cipolleschi
Last active August 9, 2020 11:27
Show Gist options
  • Select an option

  • Save cipolleschi/b575dda4ac8bb2b83fe9cabde0610339 to your computer and use it in GitHub Desktop.

Select an option

Save cipolleschi/b575dda4ac8bb2b83fe9cabde0610339 to your computer and use it in GitHub Desktop.
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
func scene(
_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions
) {
// ...
// create the view controller we need
let vc = buildViewController()
let window = UIWindow(windowScene: scene)
window.rootViewController = vc
window.makeKeyAndVisible()
self.window = window
}
func buildViewController() -> UIViewController {
#if UITESTING
// Parse the parameter using userDefaults
let initialScreen = UserDefaults.standard.string(forKey: "initialScreen")
// Switch over the possible values
if initialScreen == "home_screen" {
return HomeViewController()
}
return LegalViewController()
#endif
return LegalViewController()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment