【发布时间】:2017-03-12 11:43:59
【问题描述】:
我可以返回一个类的所有子类的列表吗?例如:
class Mother {
}
class ChildFoo: Mother {
}
class ChildBar: Mother {
}
let motherSubclasses = ... // TODO
print(motherSubclasses) // should to return [ChildFoo.self, ChildBar.self]
【问题讨论】:
-
如果不深入研究 Obj-C 运行时,我认为这是不可能的——this Q&A 可能是一个很好的起点。虽然我会质疑为什么你究竟想要这样做?
标签: swift reflection