/*
return: 有新版本返回YES
*/
-(BOOL)compareOldVer:(NSString *)oldStr newVer:(NSString *)newStr{
NSMutableArray * oldAry =[NSMutableArray arrayWithArray: [oldStr componentsSeparatedByString:@"."]];
NSMutableArray * newAry =[NSMutableArray arrayWithArray:[newStr componentsSeparatedByString:@"."]];
if(oldAry.count>newAry.count){
while (newAry.count<oldAry.count) {
[newAry addObject:@"0"];
}
}else if(newAry.count > oldAry.count){
while (oldAry.count < newAry.count) {
[oldAry addObject:@"0"];
}
}
for(int i=0;i<newAry.count;i++){
int newVal = [[newAry objectAtIndex:i] intValue];
int oldVal = [[oldAry objectAtIndex:i] intValue];
if(newVal == oldVal){
continue;
}
if(newVal>oldVal){
return YES;
}else{
return NO;
}
}
return NO;
}
ios 版本比较
最新推荐文章于 2024-10-28 15:33:49 发布