Created
June 17, 2012 15:36
-
-
Save pmj/2944868 to your computer and use it in GitHub Desktop.
Safe Objective-C cast with superclass type check
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 SSDC_CAST(TYPE, EXPR) \ | |
({ \ | |
__typeof(EXPR) _cast_expr_tmp = (EXPR); \ | |
__typeof(EXPR) _super_check_ref __attribute__((unused)) = (TYPE*)nil; \ | |
([_cast_expr_tmp isKindOfClass:[TYPE class]]) ? (TYPE*)_cast_expr_tmp : nil; \ | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment