Skip to content

Instantly share code, notes, and snippets.

@rolandkakonyi
Created July 17, 2020 12:52
Show Gist options
  • Save rolandkakonyi/3c43f6e0317b0e533664273bc76818ef to your computer and use it in GitHub Desktop.
Save rolandkakonyi/3c43f6e0317b0e533664273bc76818ef to your computer and use it in GitHub Desktop.
#define PRINT_CALLER(cmd, arg) ({ \
NSString *sourceString = [[NSThread callStackSymbols] objectAtIndex:1]; \
NSCharacterSet *separatorSet = [NSCharacterSet characterSetWithCharactersInString:@" -[]+?.,"]; \
NSMutableArray *array = [NSMutableArray arrayWithArray:[sourceString componentsSeparatedByCharactersInSet:separatorSet]]; \
[array removeObject:@""]; \
NSString *value = arg == nil ? @"nil" : [NSString stringWithFormat:@"%@", (arg)]; \
NSLog(@"Caller of '%@' is '[%@ %@]', with argument: '%@'", NSStringFromSelector(cmd), [array objectAtIndex:3], [array objectAtIndex:4], value); \
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment