Last active
July 5, 2017 18:44
-
-
Save emarashliev/900ab39490c672b04ea781e0abd18d1e to your computer and use it in GitHub Desktop.
Catch NSException in Swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation TryCatch | |
+ (void)try:(void(^_Nonnull)())try | |
catch:(nullable void(^)(NSException* _Nullable exception))catch | |
finally:(nullable void(^)())finally { | |
@try { | |
try ? try() : nil; | |
} | |
@catch (NSException *exception) { | |
catch ? catch(exception) : nil; | |
} | |
@finally { | |
finally ? finally() : nil; | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment