- 获取类的属性列表
unsigned int count;
objc_property_t *propertyList = class_copyPropertyList(self.class, &count);
for (unsigned int i = 0; i < count; i++) {
const char *propertyName = property_getName(propertyList[i]);
NSLog(@"propertyname; %@", [NSString stringWithUTF8String:propertyName]);
}
复制代码
- 获取所有成员变量
unsigned int count;
Ivar *ivarList = class_copyIvarList(self.class, &count);
for (int i = 0; i < count; i ++) {
Ivar ivar = ivarList[i];
const char *ivarName = ivar_getName(ivar);
NSLog(@"ivarName: %@", [NSString stringWithUTF8String: ivarName]);
}
复制代码
- 获取所有方法
unsigned int count;
Method *methodList = class_copyMethodList(self.class, &count);
for (int i = 0; i < count; i ++) {
Method method = methodList[i];
SEL methodName = method_getName(method);
NSLog(@"methodName: %@", NSStringFromSelector(methodName));
}
复制代码
- 获取当前所遵循的所有协议
unsigned int count;
__unsafe_unretained Protocol **protocolList = class_copyProtocolList([self class], &count);
for (int i = 0; i < count; i ++) {
Protocol *protocol = protocolList[i];
const char *protocolName = protocol_getName(protocol);
NSLog(@"protocolName: %@", [NSString stringWithUTF8String:protocolName]);
}
复制代码
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END























![[桜井宁宁]COS和泉纱雾超可爱写真福利集-一一网](https://www.proyy.com/skycj/data/images/2020-12-13/4d3cf227a85d7e79f5d6b4efb6bde3e8.jpg)

![[桜井宁宁] 爆乳奶牛少女cos写真-一一网](https://www.proyy.com/skycj/data/images/2020-12-13/d40483e126fcf567894e89c65eaca655.jpg)