Created
January 28, 2015 20:52
-
-
Save dzenbot/c7db23174681a1aba857 to your computer and use it in GitHub Desktop.
Trace a caller (from http://stackoverflow.com/questions/1451342/objective-c-find-caller-of-method)
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
NSString *sourceString = [[NSThread callStackSymbols] objectAtIndex:1]; | |
// Example: 1 UIKit 0x00540c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163 | |
NSCharacterSet *separatorSet = [NSCharacterSet characterSetWithCharactersInString:@" -[]+?.,"]; | |
NSMutableArray *array = [NSMutableArray arrayWithArray:[sourceString componentsSeparatedByCharactersInSet:separatorSet]]; | |
[array removeObject:@""]; | |
NSLog(@"Stack = %@", [array objectAtIndex:0]); | |
NSLog(@"Framework = %@", [array objectAtIndex:1]); | |
NSLog(@"Memory address = %@", [array objectAtIndex:2]); | |
NSLog(@"Class caller = %@", [array objectAtIndex:3]); | |
NSLog(@"Function caller = %@", [array objectAtIndex:4]); | |
NSLog(@"Line caller = %@", [array objectAtIndex:5]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment