class People: NSObject {
var name:String?
var age:Int = 0
var title:String?
// override init() {
// // name="dffe"
//
// // let <#name#> = <#value#>
// let cont = UInt32()
//
//
// class_copyIvarList(self, &cont)
// // super.init()
//
// }
//
class func propretyList() ->[String] {
var cont:UInt32 = 4
//这个在switf4中不行
// let list = class_copyPropertyList(self, &cont)
let list = class_copyIvarList(self, &cont)
print("属性个数(cont)")
// print(list ?? <#default value#>)
for i in 0..<Int(cont) {
let pty = list?[i]
//获取属性的名称<C语言字符串>
//转换过程:Int8 -> Byte -> Char -> C语言字符串
//let cName = property_getName(pty!)
let cName = ivar_getName(pty!)
//转换成String的字符串
let name = String(utf8String: cName!)
print(name!)
}
free(list) //释放list
return []
}
// init(name:String) {
//
// self.name=name
//
// //super.init()
// }
//
}