Catching NSException in Swift

Here is some code, that converts NSExceptions to Swift 2 errors. Now you can use do { try ObjC.catchException { /* calls that might throw an NSException */ } } catch { print(“An error ocurred: \(error)”) } ObjC.h: #import <Foundation/Foundation.h> @interface ObjC : NSObject + (BOOL)catchException:(void(^)(void))tryBlock error:(__autoreleasing NSError **)error; @end ObjC.m #import “ObjC.h” @implementation ObjC … Read more