Is it possible in Swift to create a struct that has "dynamic" properties?
i.e. if I have a dictionary that is returned from some JSON API and I know at build time that it has name
, id
in it.
Then I can build a struct like...
struct MyStruct {
let name: String
let id: String
}
But then if the dictionary has a custom attribute like age
... can I do something to add a typed property to the struct at run time?
I know (think) this sort of thing was possible with Objective-C but there was a lot more runtime control.
Is it possible in Swift?
Thanks