Skip to content

Instantly share code, notes, and snippets.

@leoschweizer
Last active January 16, 2016 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leoschweizer/dd121adf4898e0d571d1 to your computer and use it in GitHub Desktop.
Save leoschweizer/dd121adf4898e0d571d1 to your computer and use it in GitHub Desktop.
Finding the class with the longest inheritance chain in your Objective-C runtime environment with Heliograph
#import <OpinionatedC/OpinionatedC.h>
#import <Heliograph/Heliograph.h>
NSArray *classes = [HGClassMirror allClasses];
HGClassMirror *longestInheritanceChain = [classes max:^NSNumber *(HGClassMirror *each) {
return @([[each allSuperclasses] count]);
}];
NSLog(@"%@ has %lu superclasses", longestInheritanceChain, [[longestInheritanceChain allSuperclasses] count]);
// => <HGClassMirror on SASettingGetBrightness> has 9 superclasses
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment