I have a category on NSObject that defines a method with code like:
- (NSMutableDictionary *)myMethod
{
NSMutableDictionary *myDict;
if ([self isMemberOfClass:[NSObject class]]) {
myDict = [NSMutableDictionary dictionary];
}
else {
myDict = [super myMethod];
}
// DO STUFF HERE WITH myDict ...
return myDict;
}
It fails with NSObject cannot use super because it is a root class
.
I can fix this by making it a base class rather than a category and having all my subclasses inherit from that instead of from NSObject, but that seems a bit lame. [Actually, this is wrong. The compiler won't let me call super from the base class implementation, either -- but see gabriel_101's workaround, below.] Is there any way around this?