Last active
August 29, 2015 14:05
-
-
Save leviathan/72f3f94893cf62893507 to your computer and use it in GitHub Desktop.
Object discovery
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
#import <objc/runtime.h> | |
- (NSArray *)discoverAppModuleClasses | |
{ | |
NSMutableArray *appModuleClasses = [NSMutableArray array]; | |
// Integrate all classes which comply to the provider protocol | |
unsigned int count = 0; | |
Class *classList = objc_copyClassList(&count); | |
for (NSUInteger index = 0; index < count; index++) | |
{ | |
Class classReference = classList[index]; | |
if (class_conformsToProtocol(classReference, @protocol(SomeDefinedProtocolDefinition))) | |
{ | |
[appModuleClasses addObject:classReference]; | |
} | |
} | |
return appModuleClasses; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment