本文介绍了iOS +如何捕获未处理的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们正在编写静态库。我们已经为暴露的API做了异常处理。但是仍然有少数未处理的异常(或操作系统异常)。你能让我知道如何捕捉这些未处理的异常。 谢谢解决方案
嗯,你可以随时依靠 >对于这种问题,我总是使用以下代码:
@try { // do something } @catch(NSException * exception){ //发生错误!做一些关于错误状态} @finally { //做一些事情来保持程序仍然正常运行} / pre>We are writing static library. We have done exception handling for the exposed APIs. But still there are few un-handled Exceptions (or OS Exceptions). Can you please let me know how to catch these unhandled Exceptions. Thanks
解决方案Well, you could always rely on the Catch'em All Principle
For this kind of problem, I always use following code:
@try { // do something } @catch (NSException *exception) { // error happened! do something about the error state } @finally { // do something to keep the program still running properly }
更多推荐
iOS +如何捕获未处理的异常
发布评论