Here's my Struct
struct UserInfo{
struct Request:Codable{
let name = String()
}
struct Response:Codable{
let age, weight,height,birthday:String
}
}
When I get response and all if the key match that I create, ok it's good to getting every value
but what if server pass me age, weight and height only three items
That Xcode will tell me keyNotFound "birthday"
How should I prevent this situation from decoding error?
It alway causes even else's value can't get.
I have try Optional
let age, weight,height,birthday:String?
But it makes me in every VC need to set default value
My idea is if server has no birthday key I hope it just blank text
And the others still can get
Is it possible to achieve ?