Last active
December 28, 2015 22:39
-
-
Save acoomans/7573196 to your computer and use it in GitHub Desktop.
Macros for handling iOS API availabilities, disabling deprecation warnings in both clang and deploymate
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 SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame) | |
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending) | |
#define SYSTEM_VERSION_EQUAL_OR_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) | |
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) | |
#define SYSTEM_VERSION_EQUAL_OR_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending) | |
// pragmas | |
#define PRAGMA_AVAILABLE_PUSH \ | |
_Pragma("deploymate push \"ignored-api-availability\"") \ | |
_Pragma("clang diagnostic push") \ | |
_Pragma("clang diagnostic ignored \"-Wdeprecated\"") | |
#define PRAGMA_AVAILABLE_POP \ | |
_Pragma("clang diagnostic pop") \ | |
_Pragma("deploymate pop") | |
// availability if | |
#define AVAILABLE_API_IF_EQUAL_TO(v) \ | |
PRAGMA_AVAILABLE_PUSH \ | |
if SYSTEM_VERSION_EQUAL_TO(v) { | |
#define AVAILABLE_API_IF_GREATER_THAN(v) \ | |
PRAGMA_AVAILABLE_PUSH \ | |
if SYSTEM_VERSION_GREATER_THAN(v) { | |
#define AVAILABLE_API_IF_EQUAL_OR_GREATER_THAN(v) \ | |
PRAGMA_AVAILABLE_PUSH \ | |
if SYSTEM_VERSION_EQUAL_OR_GREATER_THAN(v) { | |
#define AVAILABLE_API_IF_LESS_THAN(v) \ | |
PRAGMA_AVAILABLE_PUSH \ | |
if SYSTEM_VERSION_LESS_THAN(v) { | |
#define AVAILABLE_API_IF_EQUAL_OR_LESS_THAN(v) \ | |
PRAGMA_AVAILABLE_PUSH \ | |
if SYSTEM_VERSION_EQUAL_OR_LESS_THAN(v) { | |
// availability else/end | |
#define AVAILABLE_API_ELSE } else { | |
#define AVAILABLE_API_END \ | |
} \ | |
PRAGMA_AVAILABLE_POP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment