Skip to content

Instantly share code, notes, and snippets.

@cipolleschi
Last active August 15, 2020 16:54
Show Gist options
  • Save cipolleschi/4e67fea92c0b11c3e3d9b04b61bf1066 to your computer and use it in GitHub Desktop.
Save cipolleschi/4e67fea92c0b11c3e3d9b04b61bf1066 to your computer and use it in GitHub Desktop.
func scene(
_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions
) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let scene = (scene as? UIWindowScene) else { return }
let vc = buildViewController()
#if UITESTING
self.resetIfNeeded()
#endif
let window = UIWindow(windowScene: scene)
window.rootViewController = vc
window.makeKeyAndVisible()
self.window = window
}
#if UITESTING
func resetIfNeeded() {
guard UserDefaults.standard.bool(forKey: Arguments.reset.rawValue) else {
return
}
// put the code to reset the state, remove eventual local files
// and remove the keys from the UserDefaults, if any.
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment