NSSetUncaughtExceptionHandler

NSSetUncaughtExceptionHandler

本文介绍了如何使用NSSetUncaughtExceptionHandler在Swift的UIView上显示异常消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Martin R的答案在Swift中打印NSSetUncaughtExceptionHandler。





因为我有一个编译器错误消息说,AC函数指针只能从引用func或文字闭包形成。



解决方案

的NSSetUncaughtExceptionHandler

  NSSetUncaughtExceptionHandler {
print(EXception Details Are \\\\
ExceptionName - \(exception.name)\\\
Reason - > \(exception.reason!)\\\
\(exception.description))
print(exception.callStackSymbols)
}


I use Martin R's answer to print the NSSetUncaughtExceptionHandler in Swift.

How should I use NSSetUncaughtExceptionHandler in Swift

  func exceptionHandler(exception : NSException) {

    let alert = UIAlertController(title: "Exception", message: "\(exception)", preferredStyle: .Alert)

    self.presentViewController(alert, animated: true, completion: nil)

    print(exception)
    print(exception.callStackSymbols)
}

But how can I display the message in a UIView. Like this one

Because I got a compiler error message said that "A C function pointer can only be formed from a reference to a 'func' or a literal closure."

Handling unhandled exceptions and signals written by Matt Gallagher at Cocoa with Love.

解决方案

with the use of NSSetUncaughtExceptionHandler

NSSetUncaughtExceptionHandler { exception in
            print("EXception Details Are \n\nExceptionName--> \(exception.name) \nReason -->\(exception.reason!)\n\(exception.description)")
            print(exception.callStackSymbols)
        }

这篇关于如何使用NSSetUncaughtExceptionHandler在Swift的UIView上显示异常消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 03:04