+(BOOL)hasNewVersionWithDictionary:(NSDictionary*)dictionary{
NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
NSNumber* resultCount = [dictionary objectForKey:@"resultCount"];
if ([resultCount integerValue] > 0) {
NSArray* array = [dictionary objectForKey:@"results"];
NSDictionary* dic = [array firstObject];
NSString* version = [dic objectForKey:@"version"];
NSArray* versions = [version componentsSeparatedByString:@"."];
//CFShow((__bridge CFTypeRef)(infoDic));
NSString *currentVersion = [infoDic objectForKey:@"CFBundleShortVersionString"];
NSArray* currentVersions = [currentVersion componentsSeparatedByString:@"."];
if ([versions[0] intValue] > [currentVersions[0] intValue]) {
return YES;
}else if ([versions[0] intValue] < [currentVersions[0] intValue]) {
return NO;
}else{
if ([versions[1] intValue] > [currentVersions[1] intValue]) {
return YES;
}else if ([versions[1] intValue] < [currentVersions[1] intValue]){
return NO;
}else{
if ([versions[2] intValue] > [currentVersions[2] intValue]) {
return YES;
}else{
return NO;
}
}
}
}
return NO;
}
网友评论