Skip to content

Commit

Permalink
Merge pull request Tencent#1064 from Jonas-o/master
Browse files Browse the repository at this point in the history
使用系统字符串方法去比对版本号
  • Loading branch information
MoLice authored Jul 30, 2020
2 parents a9dbab0 + d563de7 commit f5e04da
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions QMUIKit/QMUICore/QMUIHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -711,24 +711,7 @@ + (NSInteger)numbericOSVersion {
}

+ (NSComparisonResult)compareSystemVersion:(NSString *)currentVersion toVersion:(NSString *)targetVersion {
NSArray *currentVersionArr = [currentVersion componentsSeparatedByString:@"."];
NSArray *targetVersionArr = [targetVersion componentsSeparatedByString:@"."];

NSInteger pos = 0;

while ([currentVersionArr count] > pos || [targetVersionArr count] > pos) {
NSInteger v1 = [currentVersionArr count] > pos ? [[currentVersionArr objectAtIndex:pos] integerValue] : 0;
NSInteger v2 = [targetVersionArr count] > pos ? [[targetVersionArr objectAtIndex:pos] integerValue] : 0;
if (v1 < v2) {
return NSOrderedDescending;
}
else if (v1 > v2) {
return NSOrderedAscending;
}
pos++;
}

return NSOrderedSame;
return [currentVersion compare:targetVersion options:NSNumericSearch];
}

+ (BOOL)isCurrentSystemAtLeastVersion:(NSString *)targetVersion {
Expand Down

0 comments on commit f5e04da

Please sign in to comment.