Update
With Swift 2, you can pass Swift functions and closures as a pointer to a C function. See Martin R's answer below .
Original answer
You cannot starting with Xcode 6 beta 6.
Swift supports scrolling function pointers, but they are treated almost like opaque pointers. You can neither define a pointer to a C function of a Swift function, nor call a call to a C function in Swift.
This means that you are calling NSSetUncaughtExceptionHandler() from Swift, but the handler must be implemented in Objective-C. You need a header file:
volatile void exceptionHandler(NSException *exception); extern NSUncaughtExceptionHandler *exceptionHandlerPtr;
and in the implementation you need something like this:
volatile void exceptionHandler(NSException *exception) {
After importing the header file in the header of the Swift bridge, you can configure the exception handler as usual:
NSSetUncaughtExceptionHandler(exceptionHandlerPtr)
jou Aug 22 '14 at 8:17 2014-08-22 08:17
source share