2021-03-11 07:34:10 +01:00
|
|
|
//
|
|
|
|
// NSManagedObjectContext.swift
|
|
|
|
// Mastodon
|
|
|
|
//
|
|
|
|
// Created by MainasuK Cirno on 2021-3-11.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import CoreData
|
|
|
|
|
|
|
|
extension NSManagedObjectContext {
|
2022-09-30 13:28:09 +02:00
|
|
|
public func safeFetch<T>(_ request: NSFetchRequest<T>) -> [T] where T : NSFetchRequestResult {
|
2021-03-11 07:34:10 +01:00
|
|
|
do {
|
|
|
|
return try fetch(request)
|
|
|
|
} catch {
|
|
|
|
assertionFailure(error.localizedDescription)
|
|
|
|
return []
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|