如何获取当前实例的所有超类?

时间:2014-05-31 06:41:37

标签: objective-c

是否有可能追踪班级的超级课程,直到最后使用NSObject?

我在这里有一些伪代码,但它需要一些实现。

SomeObject *someObj;

id *currentParent = someObj.Parent;

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

1 个答案:

答案 0 :(得分:2)

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

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