tags:

views:

18

answers:

1

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.

+5  A: 
int level = 1;
Class cls = [UITouch class];
while (cls = [cls superclass])
  ++ level;
return level;
KennyTM