how can I fetch the property value on swift 2.0? on swift 1.0, I can get the Mirror value by value property, but I cannot find an API do this. New Mirror type on swift 2.0 only has few api. Is there any other way to achieve this?
Asked
Active
Viewed 823 times
1 Answers
2
This is the usage of reflection is swift 2.
let mirror = Mirror(reflecting: obj)
for child in mirror.children {
guard let key = child.label else {
continue
}
let value = child.value
// use value or key here
}

Thellimist
- 3,757
- 5
- 31
- 49