Skip to content

Instantly share code, notes, and snippets.

@fredriccliver
Last active April 15, 2020 20:18
Show Gist options
  • Save fredriccliver/aa5447d72cc50bf5aa1dade6603dad17 to your computer and use it in GitHub Desktop.
Save fredriccliver/aa5447d72cc50bf5aa1dade6603dad17 to your computer and use it in GitHub Desktop.
SceneDelegate.swift of Storyboard project
import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let _ = (scene as? UIWindowScene) else { return }
}
func sceneDidDisconnect(_ scene: UIScene) {}
func sceneDidBecomeActive(_ scene: UIScene) {}
func sceneWillResignActive(_ scene: UIScene) {}
func sceneWillEnterForeground(_ scene: UIScene) {}
func sceneDidEnterBackground(_ scene: UIScene) {
(UIApplication.shared.delegate as? AppDelegate)?.saveContext()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment