mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-25 04:07:47 +00:00
Compile with both Swift 4.1 and Swift 4.2
This commit is contained in:
1 parent
80956ee2c7
commit
ff595eeaef
2 files changed
+24
-8
No files matched your search
@@ -167,8 +167,13 @@ extension DatabasePool {
|
||||
public func setupMemoryManagement(in application: UIApplication) {
|
||||
self.application = application
|
||||
let center = NotificationCenter.default
|
||||
#if swift(>=4.2)
|
||||
center.addObserver(self, selector: #selector(DatabasePool.applicationDidReceiveMemoryWarning(_:)), name: UIApplication.didReceiveMemoryWarningNotification, object: nil)
|
||||
center.addObserver(self, selector: #selector(DatabasePool.applicationDidEnterBackground(_:)), name: UIApplication.didReceiveMemoryWarningNotification, object: nil)
|
||||
#else
|
||||
center.addObserver(self, selector: #selector(DatabasePool.applicationDidReceiveMemoryWarning(_:)), name: .UIApplicationDidReceiveMemoryWarning, object: nil)
|
||||
center.addObserver(self, selector: #selector(DatabasePool.applicationDidEnterBackground(_:)), name: .UIApplicationDidEnterBackground, object: nil)
|
||||
#endif
|
||||
}
|
||||
|
||||
@objc private func applicationDidEnterBackground(_ notification: NSNotification) {
|
||||
@@ -176,10 +181,13 @@ extension DatabasePool {
|
||||
return
|
||||
}
|
||||
|
||||
var task: UIBackgroundTaskIdentifier! = nil
|
||||
task = application.beginBackgroundTask(expirationHandler: nil)
|
||||
|
||||
if task == UIBackgroundTaskInvalid {
|
||||
let task: UIBackgroundTaskIdentifier = application.beginBackgroundTask(expirationHandler: nil)
|
||||
#if swift(>=4.2)
|
||||
let taskIsInvalid = task == UIBackgroundTaskIdentifier.invalid
|
||||
#else
|
||||
let taskIsInvalid = task == UIBackgroundTaskInvalid
|
||||
#endif
|
||||
if taskIsInvalid {
|
||||
// Perform releaseMemory() synchronously.
|
||||
releaseMemory()
|
||||
} else {
|
||||
|
||||
@@ -94,8 +94,13 @@ extension DatabaseQueue {
|
||||
public func setupMemoryManagement(in application: UIApplication) {
|
||||
self.application = application
|
||||
let center = NotificationCenter.default
|
||||
#if swift(>=4.2)
|
||||
center.addObserver(self, selector: #selector(DatabaseQueue.applicationDidReceiveMemoryWarning(_:)), name: UIApplication.didReceiveMemoryWarningNotification, object: nil)
|
||||
center.addObserver(self, selector: #selector(DatabaseQueue.applicationDidEnterBackground(_:)), name: UIApplication.didEnterBackgroundNotification, object: nil)
|
||||
#else
|
||||
center.addObserver(self, selector: #selector(DatabaseQueue.applicationDidReceiveMemoryWarning(_:)), name: .UIApplicationDidReceiveMemoryWarning, object: nil)
|
||||
center.addObserver(self, selector: #selector(DatabaseQueue.applicationDidEnterBackground(_:)), name: .UIApplicationDidEnterBackground, object: nil)
|
||||
#endif
|
||||
}
|
||||
|
||||
@objc private func applicationDidEnterBackground(_ notification: NSNotification) {
|
||||
@@ -103,10 +108,13 @@ extension DatabaseQueue {
|
||||
return
|
||||
}
|
||||
|
||||
var task: UIBackgroundTaskIdentifier! = nil
|
||||
task = application.beginBackgroundTask(expirationHandler: nil)
|
||||
|
||||
if task == UIBackgroundTaskInvalid {
|
||||
let task: UIBackgroundTaskIdentifier = application.beginBackgroundTask(expirationHandler: nil)
|
||||
#if swift(>=4.2)
|
||||
let taskIsInvalid = task == UIBackgroundTaskIdentifier.invalid
|
||||
#else
|
||||
let taskIsInvalid = task == UIBackgroundTaskInvalid
|
||||
#endif
|
||||
if taskIsInvalid {
|
||||
// Perform releaseMemory() synchronously.
|
||||
releaseMemory()
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user