Created
January 28, 2015 18:26
-
-
Save ashfurrow/bbb04f8272c2f32d5bb7 to your computer and use it in GitHub Desktop.
Never-null combined assertion/assignment macro
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
// From https://twitter.com/tewha/status/560497711397355520 | |
#define NEVER_NULL(a, desc, ...) ({\ | |
do {\ | |
__PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS\ | |
if ((a) == nil) {\ | |
[[NSAssertionHandler currentHandler] handleFailureInMethod:_cmd\ | |
object:self file:[NSString stringWithUTF8String:__FILE__]\ | |
lineNumber:__LINE__ description:(desc), ##__VA_ARGS__];\ | |
}\ | |
__PRAGMA_POP_NO_EXTRA_ARG_WARNINGS\ | |
} while(0);\ | |
(a);\ | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment