Skip to content

Instantly share code, notes, and snippets.

@leoschweizer
Created January 16, 2016 14:55
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/f6fc9fe822473b9de0af to your computer and use it in GitHub Desktop.
Save leoschweizer/f6fc9fe822473b9de0af to your computer and use it in GitHub Desktop.
Finding the class with the most instance variables in your Objective-C runtime environment with Heliograph
#import <OpinionatedC/OpinionatedC.h>
#import <Heliograph/Heliograph.h>
NSArray *classes = [HGClassMirror allClasses];
HGClassMirror *mostInstanceVariables = [classes max:^NSNumber *(HGClassMirror *each) {
return @([[each instanceVariables] count]);
}];
NSLog(@"%@ has %lu instance Variables", mostInstanceVariables, (unsigned long)[[mostInstanceVariables instanceVariables] count]);
// => <HGClassMirror on UIKeyboardImpl> has 125 instance Variables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment