如何处理未捕获异常

时间:2022-10-17 20:28:24

If use NSSetUncaughtExceptionHandler, it only handles objective-C runtime errors. https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/index.html#//apple_ref/c/func/NSSetUncaughtExceptionHandler

如果使用NSSetUncaughtExceptionHandler,它只处理objective-C运行时错误。https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/index.html / / apple_ref / c /函数/ NSSetUncaughtExceptionHandler

NSSetUncaughtExceptionHandler can catch the exception:

NSSetUncaughtExceptionHandler可以捕获异常:

var a: NSArray = [""]
println(a[2])

But NSSetUncaughtExceptionHandler can not catch exceptions:

但是NSSetUncaughtExceptionHandler不能捕获异常:

var a = [""]
println(a[2])

How swift deal with non-objective-C runtime errors(swift runtime errors)??

如何快速处理非objective- c运行时错误(快速运行时错误)?

1 个解决方案

#1


-3  

There has already been an exhaustively answered similar question Error-Handling in Swift-Language. Look at the first answer there which includes the latest updates in Swift 2.0 regarding this topic.

在swift语言中,类似的错误处理问题已经有了详尽的解答。请看其中的第一个答案,其中包括关于这个主题的最新的Swift 2.0更新。

#1


-3  

There has already been an exhaustively answered similar question Error-Handling in Swift-Language. Look at the first answer there which includes the latest updates in Swift 2.0 regarding this topic.

在swift语言中,类似的错误处理问题已经有了详尽的解答。请看其中的第一个答案,其中包括关于这个主题的最新的Swift 2.0更新。