Notes WWDC 2019 : Architecting Your App for Multiple Windows
Référence : Session 258 - Architecting Your App for Multiple Windows
Changes to app lifecycle
App delegate responsibilities:
- iOS 12 and before: process lifecycle and UI lifecycle
- iOS 13: process lifecycle and new scene session lifecycle; the UI lifecycle is handled by the scene delegate
Using the scene delegate
Configuring new sessions
func application(_ application: UIApplication,
configurationForConnecting connectingSceneSession: UISceneSession,
options: UIScene.ConnectionOptions) -> UISceneConfiguration
- Select a scene configuration
- Provides user activities, URLs
- Static and dynamic definition
Scene disconnection
func sceneDidDisconnect(_ scene: UIScene)
- System is releasing the scene
- May be called any time
- Release associated resources
- The scene may return
Cleaning up discarded sessions
func application(_ application: UIApplication,
didDiscardSceneSessions sceneSessions: Set<UISceneSession>)
- For permanently discarded sessions
- Delete associated data
- May be called after next launch
Architecture
Per-scene state restoration
func stateRestorationActivity(for scene: UIScene) -> NSUserActivity?
- Called on scene background
- Encode state via
NSUserActivity
- Data protection
Keeping scenes in sync
Different methods to update interface across scenes:
- Delegates
- Notifications
- Combine framework