ios - Objective-C 查找方法的调用者

标签 ios objective-c debugging nsthread

有没有办法确定调用某个方法的代码行?

最佳答案

堆栈我希望这会有所帮助:

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]);

关于ios - Objective-C 查找方法的调用者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1451342/

相关文章:

IOS 将图像保存为相机胶卷中的圆形

ios - 带有 Storyboard的呈现模态 Controller 上的导航栏

ios - 禁用在 iOS 应用程序上的 SVProgressHUD 中不起作用的用户交互

ios - 获取 invitable_friends Facebook API iOS

linux - 在崩溃(调试器)中编写脚本以打印长列表结构

ios - 无法在 iOS 开发人员中心创建分发配置文件

iphone - 用于音量控制的 IOS 音乐 api

c++ - 像在 python 和 R 中一样单步执行 C++ 程序

objective-c - iOS6 和 ACAccount : Twitter type disappears?

android - 无法解析代码路径 `FileUtils` 教程中的符号 `Todo App` (Android)