Skip to content

Instantly share code, notes, and snippets.

@cbowns
Created June 21, 2012 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbowns/2963045 to your computer and use it in GitHub Desktop.
Save cbowns/2963045 to your computer and use it in GitHub Desktop.
UIDevice System Version Preprocessor Macros
/*
System Versioning Preprocessor Macros via http://stackoverflow.com/questions/3339722/check-iphone-ios-version
Example:
if (UIDeviceSystemVersionLessThan(@"4.0")) {
// code for pre-4.0 devices.
}
if (UIDeviceSystemVersionGreaterThanOrEqualTo(@"3.1.1")) {
// Code for 3.1.1.
}
*/
#define UIDeviceSystemVersionEqualTo(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define UIDeviceSystemVersionGreaterThan(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define UIDeviceSystemVersionGreaterThanOrEqualTo(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define UIDeviceSystemVersionLessThan(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define UIDeviceSystemVersionLessThanOrEqualTo(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment