我正在尝试查找哪个属性为vars
,哪些属于let
。
使用镜像我可以得到一个对象Child,我可以从中获取标签,值的值和动态类型
let mirrored_object = Mirror(reflecting: myObject)
for property in mirrored_object.children {
// Here I have property as Child
// from which I can get
// property.label
// property.value
// property.value.dynamicType
}
但这是dynamicType,我的意思是......
let myProperty: String? <--- Will return an optional
let myProperty: String <--- Will return .Some
但我想要检测的是:
var myProperty: String
VS
let myProperty: String