How to get Class , method and line number of uncaught exception using NSSetUncaughtExceptionHandler

戏子无情 提交于 2019-12-06 09:35:20

The handler gets an instance of NSException. There are two methods: -callStackSymbols and -callStackReturnAddresses.

-callStackSymbolsgives you the backtrace strings, if it is possible.

It looks like this:

0   TestArrayCopy                       0x0000000100000dfe -[MyClass method] + 46
1   TestArrayCopy                       0x0000000100000e97 main + 87
2   libdyld.dylib                       0x00007fff940be5fd start + 1
3   ???                                 0x0000000000000001 0x0 + 1

As you can see, there is an information about the method owner (- for instance methods), the class name (MyClass) and the method name (method).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!