Skip to content

Commit ebf1d9f

Browse files
committed
ADD: add system version compare macro.
1 parent 93934fd commit ebf1d9f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Macros/VersionCompare.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* System Versioning Preprocessor Macros
3+
*/
4+
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
5+
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
6+
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
7+
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
8+
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
9+
10+
/*
11+
* Usage sample:
12+
13+
if (SYSTEM_VERSION_LESS_THAN(@"4.0")) {
14+
...
15+
}
16+
17+
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"3.1.1")) {
18+
...
19+
}
20+
21+
*/

0 commit comments

Comments
 (0)