Created
September 14, 2016 15:37
-
-
Save kolyuchiy/121800839b041e8c0f78ab64eb739968 to your computer and use it in GitHub Desktop.
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
static void LayoutLoggingForClassSelector(Class cls, SEL selector) { | |
static NSMutableDictionary *counters = nil; | |
if (!counters) { | |
counters = [NSMutableDictionary dictionary]; | |
} | |
SEL selector = NSSelectorFromString(selectorName); | |
[cls aspect_hookSelector:selector withOptions:AspectPositionBefore usingBlock:^(id<AspectInfo> info) { | |
TLLOG(NL(@"lob %s %p"), class_getName([[info instance] class]), (void *)[info instance]); | |
} error:nil]; | |
[cls aspect_hookSelector:selector withOptions:AspectPositionAfter usingBlock:^(id<AspectInfo> info) { | |
NSValue *key = [NSValue valueWithPointer:(void *)[info instance]]; | |
NSNumber *counter = counters[key]; | |
if (!counter) { | |
counter = @(0); | |
} | |
counter = @(counter.integerValue + 1); | |
counters[key] = counter; | |
TLLOG(NL(@"loa %s %p %@"), class_getName([[info instance] class]), (void *)[info instance], counter); | |
} error:nil]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment