Skip to content

Instantly share code, notes, and snippets.

@LunaCodeGirl
Last active June 29, 2017 09:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LunaCodeGirl/7303476 to your computer and use it in GitHub Desktop.
Save LunaCodeGirl/7303476 to your computer and use it in GitHub Desktop.
Macros for determining system version number in Objective-c for iPhone/iPad/iOS apps.
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1)
{
// here you go with iOS 7
}
/*
* System Versioning Preprocessor Macros
*/
#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_GREATER_THAN_OR_EQUAL_TO(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_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
/*
* Usage
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment