七牛云存储 - iOS :我获取挂在七牛上的plist文件中的爸版本号,有的时候获取的结果不一样
黄舟
黄舟 2017-04-17 13:13:01
0
1
305

NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:@"http://dn-xxxxxxxxx/HappyFaie-iphone.plist"]];

        NSArray* list = [dict objectForKey:@"items"];
    NSDictionary* dict2 = [list objectAtIndex:0];

    NSDictionary* dict3 = [dict2 objectForKey:@"metadata"];
    NSString* newVersion = [dict3 objectForKey:@"bundle-version"];

    NSString *myVersion = [NSString stringWithFormat:@"%@", [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*)kCFBundleVersionKey]];
    NSLog(@"版本号%@=====%@",newVersion,myVersion);

    if (![newVersion isEqualToString:myVersion]) {

        UIAlertView * aler = [[UIAlertView alloc] initWithTitle:@"提示" message:@"发现新版本,是否更新?" delegate:self cancelButtonTitle:@"立即更新" otherButtonTitles:@"暂不更新", nil];
        [aler show];

    }

我用这段代码获取的版本号 有时候跟写在文件里的值不一样,请问有大神知道是为什么吗?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
迷茫

This may be caused by cdn cache, causing the file you access to still be an old file, so the version number obtained will be the version number of the original file. You can go to the advanced settings of the space settings and change the new resource's Refresh the url.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!