diff --git a/GRDB/Core/DatabasePool.swift b/GRDB/Core/DatabasePool.swift index 78bf84cfc..0a9e25b6e 100644 --- a/GRDB/Core/DatabasePool.swift +++ b/GRDB/Core/DatabasePool.swift @@ -183,15 +183,20 @@ extension DatabasePool { /// as much memory as possible. private func setupMemoryManagement() { let center = NotificationCenter.default + + // Use raw notification names because of + // FB9801372 (UIApplication.didReceiveMemoryWarningNotification should not be declared @MainActor) + // TODO: Reuse UIApplication.didReceiveMemoryWarningNotification when possible. + // TODO: Reuse UIApplication.didEnterBackgroundNotification when possible. center.addObserver( self, selector: #selector(DatabasePool.applicationDidReceiveMemoryWarning(_:)), - name: UIApplication.didReceiveMemoryWarningNotification, + name: NSNotification.Name(rawValue: "UIApplicationDidReceiveMemoryWarningNotification"), object: nil) center.addObserver( self, selector: #selector(DatabasePool.applicationDidEnterBackground(_:)), - name: UIApplication.didEnterBackgroundNotification, + name: NSNotification.Name(rawValue: "UIApplicationDidEnterBackgroundNotification"), object: nil) } diff --git a/GRDB/Core/DatabaseQueue.swift b/GRDB/Core/DatabaseQueue.swift index 86799245b..2b4ddad05 100644 --- a/GRDB/Core/DatabaseQueue.swift +++ b/GRDB/Core/DatabaseQueue.swift @@ -92,15 +92,20 @@ extension DatabaseQueue { /// as much memory as possible. private func setupMemoryManagement() { let center = NotificationCenter.default + + // Use raw notification names because of + // FB9801372 (UIApplication.didReceiveMemoryWarningNotification should not be declared @MainActor) + // TODO: Reuse UIApplication.didReceiveMemoryWarningNotification when possible. + // TODO: Reuse UIApplication.didEnterBackgroundNotification when possible. center.addObserver( self, selector: #selector(DatabaseQueue.applicationDidReceiveMemoryWarning(_:)), - name: UIApplication.didReceiveMemoryWarningNotification, + name: NSNotification.Name(rawValue: "UIApplicationDidReceiveMemoryWarningNotification"), object: nil) center.addObserver( self, selector: #selector(DatabaseQueue.applicationDidEnterBackground(_:)), - name: UIApplication.didEnterBackgroundNotification, + name: NSNotification.Name(rawValue: "UIApplicationDidEnterBackgroundNotification"), object: nil) }