Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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