view GeoQuiz/Models/Controllers/CoreDataController.swift @ 26:425078c01194

refactor code
author Dennis C. M. <dennis@denniscm.com>
date Wed, 09 Nov 2022 10:30:01 +0100
parents GeoQuiz/Logic/CoreDataController.swift@f140bb277c96
children
line wrap: on
line source

//
//  CoreDataController.swift
//  GeoQuiz
//
//  Created by Dennis Concepción Martín on 22/10/22.
//

import Foundation
import SwiftUI
import CoreData

class CoreDataController {
    static func deleteGame(at offsets: IndexSet, from games: FetchedResults<PlayedGame>, with moc: NSManagedObjectContext) {
        for offset in offsets {
            let game = games[offset]
            moc.delete(game)
        }
        
        try? moc.save()
    }
}