标签:http io ar os 使用 sp for on 数据
在我们使用应用时,一打开应用,如果此应用有新的版本,常常能在应用中给出提示,是否要更新此应用。所以,我们就来看看,版本更新是如何实现的。
1
2
3
4
5
|
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@ "http://itunes.apple.com/lookup?id=%@" ,appleID]]]; [request setHTTPMethod:@ "GET" ]; NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; NSDictionary *jsonData = [NSJSONSerialization JSONObjectWithData:returnData options:0 error:nil]; |
1
2
3
|
NSString *latestVersion = [releaseInfo objectForKey:@ "version" ]; NSString *trackViewUrl1 = [releaseInfo objectForKey:@ "trackViewUrl" ]; //地址trackViewUrl NSString *trackName = [releaseInfo objectForKey:@ "trackName" ]; //trackName |
1
|
NSString *currentVersion = [infoDict objectForKey:@ "CFBundleVersion" ]; |
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary]; NSString *currentVersion = [infoDict objectForKey:@"CFBundleVersion"]; double doubleCurrentVersion = [currentVersion doubleValue]; if (doubleCurrentVersion < doubleUpdateVersion) { UIAlertView *alert; alert = [[UIAlertView alloc] initWithTitle:trackName message:@"有新版本,是否升级!" delegate: self cancelButtonTitle:@"取消" otherButtonTitles: @"升级", nil]; alert.tag = 1001; [alert show]; } else{ UIAlertView *alert; alert = [[UIAlertView alloc] initWithTitle:trackName message:@"暂无新版本" delegate: nil cancelButtonTitle:@"好的" otherButtonTitles: nil, nil]; [alert show]; }
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:trackViewUrl]];
标签:http io ar os 使用 sp for on 数据
原文地址:http://www.cnblogs.com/lingzeng/p/4135726.html