Last active
September 15, 2017 05:51
-
-
Save leilee/cef4fd0b3d5ba30b945aef94f47984f7 to your computer and use it in GitHub Desktop.
OBJC_DYNAMIC_CAST
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
| auto a = [NSMutableArray array]; | |
| if (auto array = OBJC_DYNAMIC_CAST(a, NSArray)) | |
| { | |
| // blablabla | |
| } |
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
| #if !defined(OBJC_DYNAMIC_CAST) | |
| #define OBJC_DYNAMIC_CAST(OBJECT, TYPE) ({ id obj=OBJECT;[obj isKindOfClass:[TYPE class]] ? (TYPE *) obj: nil; }) | |
| #endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment