0

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?

Community
  • 1
  • 1
McDonal_11
  • 3,935
  • 6
  • 24
  • 55

1 Answers1

0

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.

newacct
  • 119,665
  • 29
  • 163
  • 224