//得到两个类的属性
+(NSArray *)Get2ModelProperty:(Class)model1 vModel2:(Class)model2
{
//model1
u_int count;
objc_property_t *properties =class_copyPropertyList([model1 class], &count);
NSMutableArray *propertiesArray = [NSMutableArray arrayWithCapacity:count];
for (int i = 0; i < count ; i++)
{
const char* propertyName =property_getName(properties[i]);
[propertiesArray addObject: [NSString stringWithUTF8String: propertyName]];
}
free(properties);
//model2
u_int count1;
objc_property_t *properties1 =class_copyPropertyList([model2 class], &count1);
for (int i = 0; i < count1 ; i++)
{
const char* propertyName =property_getName(properties1[i]);
[propertiesArray addObject: [NSString stringWithUTF8String: propertyName]];
}
free(properties1);
return propertiesArray;
}
IOS 获取类的属性和属性个数
最新推荐文章于 2021-08-06 11:06:47 发布