如何使用NSSetUncaughtExceptionHandler获取未捕获的异常的类,方法和行号 [英] How to get Class , method and line number of uncaught exception using NSSetUncaughtExceptionHandler
本文介绍了如何使用NSSetUncaughtExceptionHandler获取未捕获的异常的类,方法和行号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用NSSetUncaughtExceptionHandler(&HandleExceptions);
处理该方法中未捕获的异常
I used NSSetUncaughtExceptionHandler(&HandleExceptions);
for handling uncaught exceptions in the method
void HandleExceptions(NSException *exception)
{
}
我想在发生任何解决方案的地方打印Class,方法和行号?
I want to print Class , method and line number where that exception occurred any solution??
我正在跟踪堆栈跟踪
0 appName 0x00000001000b6a20 HandleExceptions + 584
1 appName 0x00000001002175f0 GAIUncaughtExceptionHandler + 716
2 CoreFoundation 0x00000001852fe95c <redacted> + 692
3 libobjc.A.dylib 0x0000000195a103b4 <redacted> + 116
4 libc++abi.dylib 0x0000000195211bb4 <redacted> + 16
5 libc++abi.dylib 0x000000019521173c __cxa_rethrow + 144
6 libobjc.A.dylib 0x0000000195a10294 objc_exception_rethrow + 44
7 CoreFoundation 0x00000001851e1154 CFRunLoopRunSpecific + 572
8 GraphicsServices 0x000000018e38b5a4 GSEventRunModal + 168
9 UIKit 0x0000000189b163c0 UIApplicationMain + 1488
10 appName 0x00000001000a8584 main + 108
11 libdyld.dylib 0x000000019607ea08 <redacted> + 4
推荐答案
处理程序获取 -callStackSymbols
为您提供回溯字符串(如果可能).
-callStackSymbols
gives you the backtrace strings, if it is possible.
它看起来像这样:
0 TestArrayCopy 0x0000000100000dfe -[MyClass method] + 46
1 TestArrayCopy 0x0000000100000e97 main + 87
2 libdyld.dylib 0x00007fff940be5fd start + 1
3 ??? 0x0000000000000001 0x0 + 1
如您所见,其中包含有关方法所有者(实例方法为-
),类名(MyClass
)和方法名(method
)的信息.
As you can see, there is an information about the method owner (-
for instance methods), the class name (MyClass
) and the method name (method
).
这篇关于如何使用NSSetUncaughtExceptionHandler获取未捕获的异常的类,方法和行号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文