OBJ-C - Getting a class name from a class hierarchy
- by mmmilo
Let's say I have the following headers:
@interface SuperClass : NSObject
@interface SubClass : SuperClass
I'm alloc'ing an instance of the class by doing:
SubClass *sc = [[SubClass alloc] init];
In my SuperClass.m:
- (id) init
{
self = [super init];
if (self != nil)
{
NSString *cString = NSStringFromClass([self class]);
}
return self;
}
Simple, right? My question is: how can I get cString to return the SuperClass class, rather than the SubClass class?
Since the SubClass is alloc'd/init'd, is this not possible?
Thanks!