【发布时间】:2017-07-27 13:58:51
【问题描述】:
如何在应用程序级别处理所有未处理的异常?
我尝试使用NSSetUncaughtExceptionHandler,它只调用了 NSExceptions。
我想在应用级别处理未捕获的异常,并允许用户通过导航到主页(某些)页面继续使用应用而不会发生任何崩溃。
【问题讨论】:
标签: ios swift3 exception-handling app-store
如何在应用程序级别处理所有未处理的异常?
我尝试使用NSSetUncaughtExceptionHandler,它只调用了 NSExceptions。
我想在应用级别处理未捕获的异常,并允许用户通过导航到主页(某些)页面继续使用应用而不会发生任何崩溃。
【问题讨论】:
标签: ios swift3 exception-handling app-store
我建议您在代码中使用 try catch 块。这将有助于防止您的应用程序崩溃。
do {
try {
// do something here
// if the call fails, the catch block is executed
}
} catch {
//do something when catch block executes.
}
【讨论】: