I have the following User
Model:
struct User: Encodable, Decodable {
var uid: String
var email: String
var username: String
var created_on: String?
}
In some cases created_on
is being saved as a number
and in some cases a string
.
Is there any way to say that:
var created_on: String?
Can be a string
or number
?
At the moment its just a string
.
Reason is when im decoding
a user from firebase, if its saved as a number
, it crashes. This is because in some cases (old way I did it) it was saved as a string
, but now im saving it as a number
.