AppDelegate
This is still main entry point for iOS 13+ application. System calls appdelegate methods for application level life cycle events.
In apple’s default templet, you can find below three methods
func application(_:didFinishLaunchingWithOptions:) -> Bool
- This method is used to perform application setup.
- In iOS 12 or earlier, you might have used this method to create and configure a UIWindow object and assigned a UIViewController instance to the window to make it appear.Now appdelegate is no longer responsible for this
func application(_:configurationForConnecting:options:) -> UISceneConfiguration
- This method is called whenever your application is expected to supply a new scene, or window for iOS to display.
- This method is not called when your app launches initially, it’s only called to obtain and create new scenes
func application(_:didDiscardSceneSessions:)
This method is called whenever a user discards a scene.
You can use this function to dispose of resources that these scenes used, because they’re not needed anymore.
SceneDelegate
There are several methods in the SceneDelegate.swift file by default:
sceneDidDisconnect(_:)
is called when a scene has been disconnected from the app (Note that it can reconnect later on.)sceneDidBecomeActive(_:)
is called when the user starts interacting with a scene, such as selecting it from the app switchersceneWillResignActive(_:)
is called when the user stops interacting with a scene, for example by switching to another scenesceneWillEnterForeground(_:)
is called when a scene enters the foreground, i.e. starts or resumes from a background statesceneDidEnterBackground(_:)
is called when a scene enters the background, i.e. the app is minimised but still present in the background.
sample
Top comments (0)