Skip to content

Instantly share code, notes, and snippets.

@emarashliev
Last active December 19, 2015 20:08
Show Gist options
  • Save emarashliev/6010845 to your computer and use it in GitHub Desktop.
Save emarashliev/6010845 to your computer and use it in GitHub Desktop.
Get the class of calling object
NSString *sourceString = [[NSThread callStackSymbols] objectAtIndex:1];
NSCharacterSet *separatorSet = [NSCharacterSet characterSetWithCharactersInString:@" -[]+?.,"];
NSMutableArray *array = [NSMutableArray arrayWithArray:[sourceString componentsSeparatedByCharactersInSet:separatorSet]];
Class callerClass = NSClassFromString([array objectAtIndex:3]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment