I'm trying to get an unwrapped type from an optional type in runtime.
The following code would print the type of a as Optional<String>
.
class MySubClass: MyClass {
var a: String? = nil
}
var a = MySubClass()
let mirror = Mirror(reflecting: a)
for child in mirror.children {
print(child.value.dynamicType)
}
Now I want to unwrap the type and get String
, what should I do to make this happen in runtime?