Post

Replies

Boosts

Views

Activity

Type does not conform to protocol 'PersistentModel'
I have the following and it's working. However, if I add a new String property, it suddenly returns the error above. This new property is added as a variable, initialized and conformed to hashable accordingly. @Model final class Car { var name: String var price: Double var remarks: String? var releaseDate: Date var brand: CarBrand init(name: String, price: Double, remarks: String?, releaseDate: Date, brand: CarBrand) { self.name = name self.price = price self.remarks = remarks self.releaseDate = releaseDate self.brand = brand } } extension Car: Identifiable {} extension Car: Hashable { static func == (lhs: Car, rhs: Car) -> Bool { lhs.name == rhs.name && lhs.price == rhs.price && lhs.remarks == rhs.remarks && lhs.releaseDate == rhs.releaseDate && lhs.brand == rhs.brand } func hash(into hasher: inout Hasher) { hasher.combine(name) hasher.combine(price) hasher.combine(remarks) hasher.combine(releaseDate) hasher.combine(brand) } } enum CarBrand: String, Codable, CaseIterable, Identifiable { case brandA case brandB case brandC var id: Self { self }
2
0
2.5k
Jun ’23