Last active
May 12, 2016 01:08
-
-
Save nevyn/da531742d1aec55fb785fd27c287db86 to your computer and use it in GitHub Desktop.
This file contains 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
#define LBGuard(cond, ...) \ | |
BOOL __COND_SUCCESSFUL_AT ## __LINE__ = (cond); \ | |
if(!__COND_SUCCESSFUL_AT ## __LINE__) {\ | |
NSString *failureReason = [NSString stringWithFormat:__VA_ARGS__]; \ | |
NSAssert(NO, @"Guard failed: %@: %@", @#cond, failureReason); \ | |
NSLog(@"Guard failed: %@: %@", @#cond, failureReason);\ | |
} \ | |
if(__COND_SUCCESSFUL_AT ## __LINE__) {} | |
// Usage: | |
LBGuard([fluxCapacitor isCharged]) else { | |
*error = [NSError fluxError]; | |
return nil; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment