首页 > 代码库 > 请求苹果商店,查看商店在线版本的版本号

请求苹果商店,查看商店在线版本的版本号

    //请求苹果商店,查看商店在线版本的版本号
    [[[NSURLSession sharedSession] dataTaskWithURL:[NSURL URLWithString:@"http://itunes.apple.com/lookup?id=328266349"] completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        if (!error) {
            NSDictionary *responseObject = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
            if (responseObject.count > 0) {
                
                NSArray *array = responseObject[@"results"];
                NSDictionary *dict = [array lastObject];
                NSString *VersionString = [dict objectForKey:@"version"];
                //
                NSString* version =[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
                //
                NSComparisonResult result = [version compare:VersionString options:NSNumericSearch];
                if (result == NSOrderedAscending || result == NSOrderedSame) {
                    //
                }

            }
        }
    }]resume];

 

请求苹果商店,查看商店在线版本的版本号