Why do I get plenty of errors when trying to conform class to Codable?
class Order: ObservableObject, Codable {
enum CodingKeys: CodingKey {
case name
}
required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
name = try container.decode(String.self, forKey: .name)
}
func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(name, forKey: .name)
}
var didChange = PassthroughSubject<Void,Never>()
static let types = ["Vanilla","Chocolate", "Strawberry", "Rainbow"]
@Published var type = 0 { didSet { update() } }
@Published var quantity = 3 { didSet { update() } }
@Published var specialRequests = false { didSet { update() } }
@Published var extraSprinkles = false { didSet { update() } }
@Published var extraFrosting = false { didSet { update() } }
@Published var name = "" { didSet { update() } }
@Published var city = ""{ didSet { update() } }
@Published var streetAddress = ""{ didSet { update() } }
@Published var zip = ""{ didSet { update() } }
@Published var isValid = true{ didSet { update() } }
func update(){
didChange.send(())
}