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];
}
我用这段代码获取的版本号 有时候跟写在文件里的值不一样,请问有大神知道是为什么吗?
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.