So the other thing which came to my mind was similar to what you have
suggested:
a. Declare Displayable protocol with func display()
b. Let each Model implement this protocol
c. Within forEach on children I can just bind and typecast to the protocol
and invoke display method on it
However this lo
> Is there any other elegant way to achieve the desired behavior without
> using `if-let + typecasting`?
One way is to use classes instead on structs and define display as a method on
those classes. I’m no Swift expert but I expect you may find value in making
display() into a protocol.
An
I have 3 structs:
struct Address: Codable {
var addressLine1: String
}
struct Person: Codable {
var name: String
}
struct Order: Codable {
var person: Person?
var address: Address?
}
In my ViewController class I am using Mirror to access eac