I'm using the following struct:
struct Item : Codable {
var category:String
var birthDate:Date
var switch:Bool
var weightNew: [Weight]
var weightOld: Array<Double>
var createdAt:Date
var itemIdentifier:UUID
var completed:Bool
func saveItem() {
DataManager.save(self, with: itemIdentifier.uuidString)
}
func deleteItem() { DataManager.delete(itemIdentifier.uuidString)
}
mutating func markAsCompleted() {
self.completed = true
DataManager.save(self, with: itemIdentifier.uuidString)
}
}
And for weight:
struct Weight {
var day:Int
var weight:Double
var type:Bool
}
After changing weightOld to weightNew I get two errors: - Type 'Item' does not conform to protocol 'Decodable' - Type 'Item' does not conform to protocol 'Codable'
If I leave out 'var weightNew: [Weight]' it works. Don't know what is happening and how to solve it... Help is appreciated.
struct Weight: Codable { ... }
– Rob