ske
ske

Reputation: 5234

How to get all super classes of current instance?

Is there possible to track back the class's super classes until ending up with NSObject?

I have some pseudocode over here but it needs some implementations.

SomeObject *someObj;

id *currentParent = someObj.Parent;

while (currentParent)
{
    NSLog(@"%@",currentParent);
    currentParent = currentParent.Parent;
}

Upvotes: 0

Views: 28

Answers (1)

Warif Akhand Rishi
Warif Akhand Rishi

Reputation: 24248

SomeObject *someObj;
id currentParent = [someObj superclass];

while (currentParent)
{
    NSLog(@"%@",currentParent);
    currentParent = [currentParent superclass];
}

Upvotes: 2

Related Questions