Refer to UIApplication notifications by their names

It looks like FB9801372 was fixed
This commit is contained in:
Gwendal Roué authored and Gwendal Roué committed 2022-08-21 21:22:34 +02:00
1 parent a20d543bcf
commit 33a039717c
3 files changed
+7 -17

No files matched your search

+2 -7
View File
@@ -214,20 +214,15 @@ 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: NSNotification.Name(rawValue: "UIApplicationDidReceiveMemoryWarningNotification"),
name: UIApplication.didReceiveMemoryWarningNotification,
object: nil)
center.addObserver(
self,
selector: #selector(DatabasePool.applicationDidEnterBackground(_:)),
name: NSNotification.Name(rawValue: "UIApplicationDidEnterBackgroundNotification"),
name: UIApplication.didEnterBackgroundNotification,
object: nil)
}
+2 -7
View File
@@ -93,20 +93,15 @@ 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: NSNotification.Name(rawValue: "UIApplicationDidReceiveMemoryWarningNotification"),
name: UIApplication.didReceiveMemoryWarningNotification,
object: nil)
center.addObserver(
self,
selector: #selector(DatabaseQueue.applicationDidEnterBackground(_:)),
name: NSNotification.Name(rawValue: "UIApplicationDidEnterBackgroundNotification"),
name: UIApplication.didEnterBackgroundNotification,
object: nil)
}
@@ -59,7 +59,7 @@ class DatabasePoolReleaseMemoryTests: GRDBTestCase {
// Simulate memory warning.
NotificationCenter.default.post(
name: NSNotification.Name(rawValue: "UIApplicationDidReceiveMemoryWarningNotification"),
name: UIApplication.didReceiveMemoryWarningNotification,
object: nil)
// Postcondition: reader connection was closed
@@ -87,7 +87,7 @@ class DatabasePoolReleaseMemoryTests: GRDBTestCase {
// Simulate memory warning.
NotificationCenter.default.post(
name: NSNotification.Name(rawValue: "UIApplicationDidReceiveMemoryWarningNotification"),
name: UIApplication.didReceiveMemoryWarningNotification,
object: nil)
// Postcondition: no reader connection was closed
@@ -108,7 +108,7 @@ class DatabasePoolReleaseMemoryTests: GRDBTestCase {
// Simulate memory warning.
NotificationCenter.default.post(
name: NSNotification.Name(rawValue: "UIApplicationDidReceiveMemoryWarningNotification"),
name: UIApplication.didReceiveMemoryWarningNotification,
object: nil)
// Make sure we can read