Skip to content

Instantly share code, notes, and snippets.

@akisute
Created June 16, 2013 05:41
Show Gist options
  • Save akisute/5790904 to your computer and use it in GitHub Desktop.
Save akisute/5790904 to your computer and use it in GitHub Desktop.
Great example code of how to detect major version of running iOS. Uses dispatch_once for performance.
NSUInteger DeviceSystemMajorVersion();
NSUInteger DeviceSystemMajorVersion() {
static NSUInteger _deviceSystemMajorVersion = -1;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_deviceSystemMajorVersion = [[[[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."] objectAtIndex:0] intValue];
});
return _deviceSystemMajorVersion;
}
#define MY_MACRO_NAME (DeviceSystemMajorVersion() < 7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment