Last active
September 29, 2015 18:58
-
-
Save masakih/1650664 to your computer and use it in GitHub Desktop.
クラス階層表示 ref: http://qiita.com/items/1823
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void printClassHierarchy(id object) | |
| { | |
| NSMutableArray *names = [NSMutableArray array]; | |
| Class objClass = [object class]; | |
| Class rootClass = [NSObject class]; | |
| while(objClass != rootClass) { | |
| [names addObject:NSStringFromClass(objClass)]; | |
| objClass = [objClass superclass]; | |
| } | |
| [names addObject:NSStringFromClass(rootClass)]; | |
| int i = 0; | |
| for(NSString *name in [names reverseObjectEnumerator]) { | |
| fprintf(stderr, "%*s%s\n", i++ * 4, " ", [name UTF8String]); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment