How to catch a Swift crash and do some logging

后端 未结 4 1946
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-16 13:48

In Objective-C, the NSSetUncaughtExceptionHandler can register some functionality to do some last minute logging about the exception.

This doesn\'t catc

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-16 14:22

    Swift 5 you can handle app crash like this

    NSSetUncaughtExceptionHandler { (exception) in
       let stack = exception.callStackReturnAddresses
       print("Stack trace: \(stack)")
    
        }
    

提交回复
热议问题