美文网首页
iOS检测新版本

iOS检测新版本

作者: 今年27 | 来源:发表于2019-11-01 18:40 被阅读0次
    +(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;
        
    }
    

    相关文章

      网友评论

          本文标题:iOS检测新版本

          本文链接:https://www.haomeiwen.com/subject/ytcmectx.html