Skip to content

Instantly share code, notes, and snippets.

@albertodebortoli
Last active December 25, 2015 03:29
Show Gist options
  • Select an option

  • Save albertodebortoli/6910168 to your computer and use it in GitHub Desktop.

Select an option

Save albertodebortoli/6910168 to your computer and use it in GitHub Desktop.
Compare string versions
+ (BOOL)currentVersionIsGreaterOrEqualThan:(NSString *)baseVersion
{
// baseVersion is something like @"1.0.5"
NSArray *baseVersionComponents = [baseVersion componentsSeparatedByString:@"."];
NSString *version = [UIDevice currentDevice].systemVersion;
NSArray *components = [version componentsSeparatedByString:@"."];
// the number of components of both version must be the same
for (int i = 0; i < [components count]; i++) {
if ([components[i] integerValue] < [baseVersionComponents[i] integerValue]) {
return NO;
}
}
return YES;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment