Lets say I have this class:
class Node {
var value: String
var children: Array<Node>? = nil
}
If I have the name of one of its properties (for example "children"
) how can I get its type? (In this case case Array<String>?
)
I imagine having a global function like below will solve my needs
func typeOfPropertyWithName(name: String, ofClass:AnyClass) -> AnyClass? {
???
}
// Example usage:
var arrayOfNodesClass = typeOfPropertyWithName("children", Node.self)
Aucun commentaire:
Enregistrer un commentaire