dimanche 5 mai 2019

Get all nested types of a type in Swift (as metatypes references)

I have some nested classes definition in Swift, like:

class Animal {
    class Mammal {
        class Tiger {}
        class Wolf {}
    }
    class Bird {} 
}

Is it possible to introspect this hierarchy to automatically get an array of metatypes from it, like this, but in runtime:

[
    Animal.self,
    Animal.Mammal.self,
    Animal.Mammal.Tiger.self,
    Animal.Mammal.Wolf.self,
    Animal.Bird.self,
    Animal.self,
]





Aucun commentaire:

Enregistrer un commentaire