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

    //请求苹果商店,查看商店在线版本的版本号
    [[[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];

 

posted @ 2017-01-03 10:36  Nuius  阅读(427)  评论(0编辑  收藏  举报