Skip to content

Instantly share code, notes, and snippets.

@cbowns cbowns/gist:2963045
Created Jun 21, 2012

Embed
What would you like to do?
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
You can’t perform that action at this time.