Here is part of the Vehicle structure. I've left out some unrelated things like various functions.
@Model
final class Vehicle: Equatable, ContainsListItem {
var id: UUID
// Other variables here...
var mileageHistory: [Mileage] = []
Below is what the init look like when it has an issue.
init(from vehicle: Vehicle) {
self.id = vehicle.id
self.timestamp = vehicle.timestamp
self.year = vehicle.year
self.make = vehicle.make
self.model = vehicle.model
self.trim = vehicle.trim
self.mileage = vehicle.mileage
self.nickname = vehicle.nickname
self.mileageHistory = vehicle.mileageHistory
}
As a reminder, if you remove that last line in the init everything will work fine. If that line is there, a copy of Vehicle is being created and inserted into the context without me explicitly doing that.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: