mirror of
https://github.com/AU-COVIDSafe/mobile-ios.git
synced 2025-04-05 14:24:59 +00:00
26 lines
792 B
Swift
26 lines
792 B
Swift
//
|
|
// Encounter+Util.swift
|
|
// CovidSafe
|
|
//
|
|
// Copyright © 2020 Australian Government. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import CoreData
|
|
|
|
extension Encounter {
|
|
@nonobjc public class func deleteAll() {
|
|
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
|
|
return
|
|
}
|
|
appDelegate.persistentContainer.performBackgroundTask { (backgroundContext) in
|
|
let oldFetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "Encounter")
|
|
let batchDeleteRequest = NSBatchDeleteRequest(fetchRequest: oldFetchRequest)
|
|
do {
|
|
try backgroundContext.execute(batchDeleteRequest)
|
|
} catch {
|
|
DLog("Error deleting old data \(error)")
|
|
}
|
|
}
|
|
}
|
|
}
|