Ios 如何在不启动Swift中的新对象的情况下列出所有类属性?
我尝试使用Ios 如何在不启动Swift中的新对象的情况下列出所有类属性?,ios,swift,Ios,Swift,我尝试使用Mirror列出所有类属性 Mirror(reflecting: Person(name: "a", age: 1)).children.count Mirror(reflecting: Person.self).children.count 从上面的代码。第一行返回正确,但第二行与第一行不同 如果我想列出所有类属性而不启动新对象。我该怎么做 多谢各位 Mirror(reflecting: Person()).children.count 把self改成()。你会得到你想要的结果
Mirror
列出所有类属性
Mirror(reflecting: Person(name: "a", age: 1)).children.count
Mirror(reflecting: Person.self).children.count
从上面的代码。第一行返回正确,但第二行与第一行不同
如果我想列出所有类属性而不启动新对象。我该怎么做
多谢各位
Mirror(reflecting: Person()).children.count
把self改成()。你会得到你想要的结果 问题解决了吗?在我的问题中,我想在不启动新对象的情况下执行此操作,但对于您的回答,
Person()
是启动Person对象的方法,不是吗?不,它不会启动新对象。