获取object各个元素的key

//MARK: - 获取object各个元素的key
    public class func getKey() ->Array<Any> {
        
        var ivarNum : u_int = 0
        let ivars = class_copyIvarList(self, &ivarNum)
        var mArray = Array<Any>()
        
        for index in 0..<numericCast(ivarNum) {
            
            let ivarNameC = ivar_getName(ivars?[index])
            
            let str = String.init(utf8String: ivarNameC!)
            
            mArray.append(str!)
            
        }
        free(ivars)
        
        return mArray
    }

推荐阅读更多精彩内容