Created
January 16, 2016 12:55
-
-
Save leoschweizer/5e2fae183fe4cb53dbde to your computer and use it in GitHub Desktop.
Finding the longest method name in your Objective-C runtime environment with Heliograph
This file contains 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
#import <OpinionatedC/OpinionatedC.h> | |
#import <Heliograph/Heliograph.h> | |
NSArray *classes = [HGClassMirror allClasses]; | |
NSMutableArray *methods = [NSMutableArray array]; | |
[classes each:^(HGClassMirror *each) { | |
// add the instance methods of the reflected class | |
[methods addObjectsFromArray:[each methods]]; | |
// add the class methods of the reflected class | |
[methods addObjectsFromArray:[[each classMirror] methods]]; | |
}]; | |
HGMethodMirror *maxSelector = [methods max:^NSNumber *(HGMethodMirror *each) { | |
return @(NSStringFromSelector([each selector]).length); | |
}]; | |
NSLog(@"%@ defined in %@", NSStringFromSelector([maxSelector selector]), maxSelector.definingClass); | |
// => shapeEffectSingleBlurFrom:withInteriorFill:offset:blurSize:innerGlowRed:innerGlowGreen:innerGlowBlue:innerGlowOpacity:innerShadowRed:innerShadowGreen:innerShadowBlue:innerShadowOpacity:outerGlowRed:outerGlowGreen:outerGlowBlue:outerGlowOpacity:outerShadowRed:outerShadowGreen:outerShadowBlue:outerShadowOpacity:hasInsideShadowBlur:hasOutsideShadowBlur: defined in <HGClassMirror on CUIShapeEffectStack class> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment