I seek help in understanding why code behaves so strange. What I have: BaseClass : NSManagedObject and ChildClass : BaseClass
BaseClass has a category. .h:
@interface BaseClass (Category)
+ (NSArray)method;
@end
.m:
@implementation BaseClass (Category)
+ (NSArray *)method
{
if ([self isKindOfClass:[ChildClass class]) {
do stuff
return resultArray;
}
return nil;
}
From another place in project I call *array = [ChildClass method];. In the BaseClass (Category) implementation console reads self = (Class)ChildClass, but still the execution flow skips the if and passes right to return nil; for some reason, that is beyond my understanding. Any suggestions why that may be? All answers are appreciated. Thanks.
… as I don’t have enough rep points, I’m not posting the screenshots. Hope I was clear.
You’re in a static method, so self represents the class itself. Is enough to do this: