通过 class_copyPropertyList 获取到全部的属性列表 然后通过遍历的方式取出key值 就是我们说的属性的名称
- (NSArray*)cf_KeysWithValues:(LoginResultModel*)model {
NSMutableArray *array = [[NSMutableArray alloc]init];
unsignedintcount ,i;
objc_property_t*propertyArray =class_copyPropertyList([LoginResultModelclass], &count);
for(i =0; i < count; i++) {
objc_property_tproperty = propertyArray[i];
NSString *proKey = [NSString stringWithCString:property_getName(property) encoding:NSUTF8StringEncoding];
[array addObject:proKey];
}
return [array copy];
}
这里我传入一个model 得到的就是我里面的属性列表的数组


网友评论