lundi 16 mai 2016

Swift Mirror reflection capabilities - get all instances of a class/protocol

I've been curious how exactly can I using Swift 2.2 derive all instances of a particular superclass or protocol?

Consider the following example:

protocol FooBar {

}

public class Foo : FooBar {

}

public class Bar : FooBar {

}

Whereas the result I would like to get using Swift's reflection capabilities is a list of all instances of a particular superclass or protocol, as in this example Foo and Bar.





Aucun commentaire:

Enregistrer un commentaire