代码示例如下:
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"版本检测更新";
self.view.backgroundColor = [UIColor whiteColor];
[self checkVersion]; //检测升级
}
-(void)checkVersion
{
NSString *newVersion;
NSURL *url = [NSURL URLWithString:@"http://itunes.apple.com/cn/lookup?id=1139094792"];//这个URL地址是该app在iTunes connect里面的相关配置信息。其中id是该app在app store唯一的ID编号。
NSString *jsonResponseString = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
NSLog(@"通过appStore获取的数据信息:%@",jsonResponseString);