I have a string with the name of a class and I'm trying to get the framework name where the class belongs.
Things that I have tried:
- bundleForClass
Class *myClass = NSClassFromString(@"ClassName");
[NSBundle bundleForClass:myClass];
But I can't seem to make it work with relocatable / static mach-o type.
- Adding new method on NSObject using categories
// This is on NSObject+ModuleID.h
@interface NSObject (ModuleID)
- (NSString *) moduleIdentifier;
@end
// This is on NSObject+ModuleID.m
@implementation NSObject (ModuleID)
- (NSString *) moduleIdentifier { return @"Framework Name"; }
@end
Class *myClass = NSClassFromString(@"ClassName");
[myClass moduleIdentifier];
This doesn't work since the project include more than 1 framework.
- Adding a new string property containing the framework name to each class in the frameworks
-(NSString *)moduleIdentifier
{ return @"Framework Name"; }
This is not feasible considering the number of the classes easily exceeds a hundred.
Is there any way to do this? Any input would be appreciated, thanks!