Last active
December 25, 2015 03:29
-
-
Save albertodebortoli/6910168 to your computer and use it in GitHub Desktop.
Compare string versions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| + (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