Is the a way to get the number of ancestors for an instance of class? E.g. a class of type UITouch would be of level 2 as it inherits from NSObject.
int level = 1;
Class cls = [UITouch class];
while (cls = [cls superclass])
++ level;
return level;
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