iOS +如何捕获未处理的异常

编程入门 行业动态 更新时间:2024-10-24 01:49:31
本文介绍了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 +如何捕获未处理的异常

本文发布于:2023-11-17 11:55:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609924.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:异常   未处理   iOS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!