问题描述
我的小任务是如何发送崩溃报告?我不知道这个例子是对还是错.
My small task is, how to mail crash report? I don't know whether this example is right or wrong.
编码:
override func viewDidLoad() {
super.viewDidLoad()
func exceptionHandler(exception : NSException) {
print("\n\n \(exception)")
print("\n\n \(exception.callStackSymbols)")
mailAcn() // SENDING MAIL ACTION WHEN EXCEPTION CAUGHT
}
NSSetUncaughtExceptionHandler(exceptionHandler) //Error: A C Function pointer cannot be formed from a local function captures context
// Do any additional setup after loading the view, typically from a nib.
}
我正在跟踪此链接,如何使用NSSetUncaughtExceptionHandler在UIView上显示异常消息在Swift
I am following this link,,How to use NSSetUncaughtExceptionHandler to show exception message on UIView in Swift
正在接收一些未知错误.请指导我,如何解决这个问题?
Some unknown error is receiving. Kindly guide me, how to solve this?
推荐答案
mailAcn()
表示self.mailAcn()
,即它正在self
上调用实例方法.因此,该函数从周围的范围捕获变量self
,因此不能用作C函数.
mailAcn()
means self.mailAcn()
, i.e. it is calling an instance method on self
. Thus, the function captures the variable self
from the surrounding scope, and it cannot be used as a C function.
您可以尝试将mailAcn
设为顶级功能.
You can try to make mailAcn
a top-level function instead.
这篇关于Xcode7:如何快速发送崩溃报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!