Class named B inherits from A (B : A)
[[B class] isKindOfClass:[A class]]
returns NO
doing
[[B new] isKindOfClass:[A class]]
returns YES
so the left caller must be an instance, but how to do the same with a Class ?
- (BOOL)isKindOfClass:(Class)aClass
is indeed an instance method (note the -) and won't work on the class
+ (BOOL)isSubclassOfClass:(Class)aClass
is a class method (note the +) and that's what you're looking for.
But wait ! NSObject Class Reference tells us “Refer to a class only by its name when it is the receiver of a message. In all other cases [...] use the class method.”
So you will use :
[B isSubclassOfClass:[A class]]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With