Spot the wrong scene lifecycle callback used to persist data before suspension.
Codeswift
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// Called when the scene moves from inactive to active state
func sceneDidBecomeActive(_ scene: UIScene) {
GameTimer.shared.resume()
}
// Intended to persist unsaved changes before the app is suspended
func sceneWillEnterForeground(_ scene: UIScene) {
PersistenceManager.shared.save()
}
}
The developer wants to persist data before the app gets suspended in the background. What is the bug in this code?