import Foundation
import CoreData
class CoreDataStack {
var container: NSPersistentContainer {
let container = NSPersistentContainer(name: "todos")
container.viewContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
container.loadPersistentStores { (description, error) in
guard error == nil else {
print("Error: \(error!)")
return
}
}
return container
}
var managedContext: NSManagedObjectContext {
return container.viewContext
}
}