Impressia/Vernissage/CoreData/AttachmentDataHandler.swift

28 lines
806 B
Swift
Raw Normal View History

2023-01-01 18:13:36 +01:00
//
// https://mczachurski.dev
// Copyright © 2023 Marcin Czachurski and the repository contributors.
// Licensed under the MIT License.
//
import Foundation
2023-01-02 08:11:38 +01:00
import CoreData
2023-01-01 18:13:36 +01:00
class AttachmentDataHandler {
func getAttachmentsData() -> [AttachmentData] {
let context = CoreDataHandler.shared.container.viewContext
let fetchRequest = AttachmentData.fetchRequest()
do {
return try context.fetch(fetchRequest)
} catch {
print("Error during fetching accounts")
return []
}
}
2023-01-02 08:11:38 +01:00
func createAttachmnentDataEntity(viewContext: NSManagedObjectContext? = nil) -> AttachmentData {
let context = viewContext ?? CoreDataHandler.shared.container.viewContext
2023-01-01 18:13:36 +01:00
return AttachmentData(context: context)
}
}