In my code, I have an array of a class that may not have any members at the point where I want to get the properties through reflection. Mirror(reflecting:) requires an instance but I'm stuck at how to deal with this if I don't have any instances yet.
Here's how Apple's documentation shows an example of reflection:
struct Point {
let x: Int, y: Int
}
let p = Point(x: 21, y: 30)
print(String(reflecting: p))
// Prints "▿ Point
// - x: 21
// - y: 30"
To simplify my scenario, essentially what I want to do is mirror "Point" rather than "p".
Any ideas?
Aucun commentaire:
Enregistrer un commentaire