I have the following:
struct myModel: Decodable, Identifiable {
let id = UUID()
let a, b, c: String
}
I’m getting the following warning:
Immutable property will not be decoded because it is declared with an initial value which cannot be overwritten
I don’t want to change the id once the data is refreshed, I just want to assign it once. How can I get rid of that warning?
>Solution :
Either declare id as var or add CodingKeys and omit id.
And please name structs and classes always with starting capital letter
struct MyModel: Decodable, Identifiable {
private enum CodingKeys: String, CodingKey { case a, b, c }
let id = UUID()
let a, b, c: String
}
