如何捕捉全球例外? [英] How do I catch global exceptions?
本文介绍了如何捕捉全球例外?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在代码中捕获全局崩溃的应用程序异常,如objc_exception_throw,EXC_ARITHMETIC等?我需要这个,因为我想在应用程序被系统杀死之前做一些事情。
Is there a way to catch global "crashing" app exceptions like objc_exception_throw, EXC_ARITHMETIC etc. in code? I need that because I want to do some things before the app gets killed by the system.
推荐答案
你可以设置一个处理程序使用 NSSetUncaughtExceptionHandler
的任何未捕获的异常。
You can set a handler for any uncaught exception by using NSSetUncaughtExceptionHandler
.
The relevant docs from Apple are here: http://developer.apple.com/mac/library/documentation/cocoa/conceptual/Exceptions/Concepts/UncaughtExceptions.html#//apple_ref/doc/uid/20000056-BAJDDGGD
这篇关于如何捕捉全球例外?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文