appdelegate swift 3

时间:2017-07-27 13:58:51

标签: ios swift3 exception-handling app-store

如何处理应用程序级别中所有未处理的异常?

我尝试使用NSSetUncaughtExceptionHandler,它仅调用NSExceptions。

我想在应用级别处理未捕获的异常,并允许用户通过导航到主页(某些)页面继续使用应用程序而不会出现任何崩溃。

1 个答案:

答案 0 :(得分:0)

我建议你在代码中使用try catch块。它有助于防止应用程序崩溃。

do {
    try {
    // do something here
    // if the call fails, the catch block is executed
}
} catch {
    //do something when catch block executes.
}