本方法可适用于以下场景,
前提是想查的方法都存在于三方静态库动态库中,无法直接搜索字符串得到
场景1:只知道方法名,如何找到这个方法所在的类名
场景2:已知一个类有某个方法,怎么知道有没有其他的类也声明实现了相同的方法
场景3:对于系统提供的某个代理方法,如何一次性全部加上断点,来查看当前业务使用的是哪个类的这个方法。比如被封装的网络请求,我们如何知道是最终的哪个类发出去的
这就是要说的符号断点
以网络请求的这个代理方法为例 URLSession:dataTask:didReceiveResponse:completionHandler:
这个方法系统的声明如下
@protocol NSURLSessionDataDelegate <NSURLSessionTaskDelegate>
@optional
/* The task has received a response and no further messages will be
* received until the completion block is called. The disposition
* allows you to cancel a request or to turn a data task into a
* download task. This delegate message is optional - if you do not
* implement it, you can get the response as a property of the task.
*
* This method will not be called for background upload tasks (which cannot be converted to download tasks).
*/
- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask
didReceiveResponse:(NSURLResponse *)response
completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler;
是一个可选代理方法
在xcode中设置符号断点的步骤是
1.和2.参照下图 点击
3.然后点 Symbolic Breakpoint...
4.在弹出的框中 Symbol 一行输入方法名,其他的空着就可以
注意:输入的时候直接输入:URLSession:dataTask:didReceiveResponse:completionHandler:
不要带类的名字,比如:[HttpTool URLSession:dataTask:didReceiveResponse:completionHandler:]
如下图 这是正在输入时候的截图
输入完之后会如下图显示
这时还看不到具体的断点,然后运行工程
所有的断点就都出来了,
后面还标着是哪个库
点击某个业务功能,看断点停在哪个,就能找到使用的哪个请求方法了