struct Person{
var name:String
var age:Int
var height:Double?
}
let aPerson = Person(name:"xijinping",age:48,height:180) let structMirror = Mirror(reflecting: aPerson).children let numChildren = structMirror.count print("child count:\(numChildren)") for case let (key,value) in structMirror { print("name: \(key) value: \(value)") }
原文链接:https://www.f2er.com/swift/322903.html