Swift运行时: 获取类的属性列表

2016-08-05  本文已影响15人  Michael_NO1

```

class func propertyList() -> [String] {    

        var count: UInt32 = 0    

        let list = class_copyPropertyList(self,&count)    

       for i in 0..<Int(count) {

               let pty = list?[i]

               let  cName = property_getName(pty!)

               let name = String(utf8String: cName!)

       }

        free(list)

        return []

}

上一篇 下一篇

猜你喜欢

热点阅读