Created
February 29, 2012 11:21
-
-
Save valexa/1940170 to your computer and use it in GitHub Desktop.
conformsToProtocol
This file contains hidden or 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
int class_count = objc_getClassList(nil, 0); | |
Class *buffer = calloc(class_count, sizeof(Class)); | |
if (buffer) { | |
//NSLog(@"allocated a %d bytes buffer",malloc_size(buffer)); | |
objc_getClassList(buffer,class_count); | |
//NSLog(@"total %i classes",class_count); | |
for (int i = 0; i < class_count; ++i) { | |
Class currClass = buffer[i]; | |
if ( class_respondsToSelector(currClass, @selector(conformsToProtocol:)) ) { | |
if ([currClass conformsToProtocol:@protocol(NSMutableCopying)]) { | |
NSString *className = NSStringFromClass(currClass); | |
NSLog(@"%@",className); | |
} | |
} | |
} | |
free(buffer); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment