ios 如何在其他线程中打印主线程的回溯?

soat7uwm  于 2023-10-21  发布在  iOS
关注(0)|答案(2)|浏览(141)

如何在其他线程中打印主线程的回溯?
而在其他线程,我想打印的主要thread.is的回溯有任何sanple代码给我?

pcrecxhr

pcrecxhr1#

执行以下操作:

dispatch_async(dispatch_get_main_queue(), ^{
   NSLog(@"Trace = %@", [NSThread callStackSymbols]);
});
py49o6xq

py49o6xq2#

查看代码(GPL v3):BSBacktraceLogger

+ (NSString *)bs_backtraceOfCurrentThread {
    return [self bs_backtraceOfNSThread:[NSThread currentThread]];
}

+ (NSString *)bs_backtraceOfMainThread {
    return [self bs_backtraceOfNSThread:[NSThread mainThread]];
}

相关问题