Untitled
unknown
plain_text
2 years ago
920 B
6
Indexable
//
// Item.CoreDataAdapters.swift
// ShoppingList
//
// Created by Marco on 14/03/24.
//
import Foundation
/// CoreData managed objects <=> App entities adapters
extension Model.Entity.Items.Item: ForeignModelAdapter {
func adaptExistingForeignModel(_ model: inout Item) {
model.title = self.title
model.notes = self.notes
model.price = self.price
model.priority = self.priority
model.completed = self.completed
model.timestamp = self.dateAdded
}
static func newEntity(from coreDataModel: Item) -> Model.Entity.Items.Item {
return .init(id: coreDataModel.id?.uuidString ?? "",
title: coreDataModel.title ?? "",
notes: coreDataModel.notes,
priority: coreDataModel.priority,
price: coreDataModel.price,
completed: coreDataModel.completed,
dateAdded: coreDataModel.timestamp)
}
}Editor is loading...
Leave a Comment