Xcode7: How to mail crash report in swift

情到浓时终转凉″ 提交于 2019-12-25 09:16:07

问题


My small task is, how to mail crash report? I don't know whether this example is right or wrong.

Coding:

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.
    }

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?


回答1:


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.

You can try to make mailAcn a top-level function instead.



来源:https://stackoverflow.com/questions/39265162/xcode7-how-to-mail-crash-report-in-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!