Skip to content

Instantly share code, notes, and snippets.

@RandyMcMillan
Created April 14, 2012 02:13
Show Gist options
  • Save RandyMcMillan/2381583 to your computer and use it in GitHub Desktop.
Save RandyMcMillan/2381583 to your computer and use it in GitHub Desktop.
iOS3 / iOS4 / iOS5 threshold switch
NSString* systemVersion = [[UIDevice currentDevice] systemVersion];
BOOL isLessThaniOS4 = ([systemVersion compare:@"4.0" options:NSNumericSearch] == NSOrderedAscending);
BOOL isGreaterThaniOS4 = ([systemVersion compare:@"4.0" options:NSNumericSearch] == NSOrderedDescending);
BOOL isLessThaniOS5 = ([systemVersion compare:@"5.0" options:NSNumericSearch] == NSOrderedAscending);
BOOL isGreaterThaniOS5 = ([systemVersion compare:@"5.0" options:NSNumericSearch] == NSOrderedDescending);
if (isLessThaniOS4 && isLessThaniOS5)
{
//NSLog(@"isLessThaniOS4 && isLessThaniOS5 = %@",whatever);
}
if ( isGreaterThaniOS4 && isLessThaniOS5)
{
//NSLog(@"isGreaterThaniOS4 && isLessThaniOS5 = %@",whatever);
}
if (isGreaterThaniOS5)
{
//NSLog(@"isGreaterThaniOS5 = %@",whatever);
}
@RandyMcMillan
Copy link
Author

Convoluted is an understatement...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment