Created
November 21, 2019 12:09
-
-
Save qy1010/64a2c71ae23ee29e08f0bc0ded466419 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(@"property---->%@", [NSString stringWithUTF8String:propertyName]); | |
} | |
//获取方法列表 | |
Method *methodList = class_copyMethodList([self class], &count); | |
for (unsigned int i; i<count; i++) { | |
Method method = methodList[i]; | |
NSLog(@"method---->%@", NSStringFromSelector(method_getName(method))); | |
} | |
//获取成员变量列表 | |
Ivar *ivarList = class_copyIvarList([self class], &count); | |
for (unsigned int i; i<count; i++) { | |
Ivar myIvar = ivarList[i]; | |
const char *ivarName = ivar_getName(myIvar); | |
NSLog(@"Ivar---->%@", [NSString stringWithUTF8String:ivarName]); | |
} | |
//获取协议列表 | |
__unsafe_unretained Protocol **protocolList = class_copyProtocolList([self class], &count); | |
for (unsigned int i; i<count; i++) { | |
Protocol *myProtocal = protocolList[i]; | |
const char *protocolName = protocol_getName(myProtocal); | |
NSLog(@"protocol---->%@", [NSString stringWithUTF8String:protocolName]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment