//获取AppStore上的版本号
NSString *url = [[NSStringalloc]initWithFormat:@"http://itunes.apple.com/lookup?id=%@",@"1063983037"];//后数字修改成自己项目的APPID
[self Postpath:url];
#pragma mark -- 获取AppStore上的版本号
-(void)Postpath:(NSString *)path
{
NSURL *url = [NSURLURLWithString:path];
NSMutableURLRequest *request = [NSMutableURLRequestrequestWithURL:url
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:10];
[request setHTTPMethod:@"POST"];
NSOperationQueue *queue = [NSOperationQueuenew];
[NSURLConnectionsendAsynchronousRequest:requestqueue:queuecompletionHandler:^(NSURLResponse *response,NSData *data,NSError *error){
NSMutableDictionary *receiveStatusDic=[[NSMutableDictionaryalloc]init];
if (data) {
NSDictionary *receiveDic = [NSJSONSerializationJSONObjectWithData:dataoptions:NSJSONReadingMutableLeaveserror:nil];
if ([[receiveDicvalueForKey:@"resultCount"]intValue]>0) {
[receiveStatusDic setValue:@"1"forKey:@"status"];
[receiveStatusDic setValue:[[[receiveDicvalueForKey:@"results"]objectAtIndex:0]valueForKey:@"version"] forKey:@"version"];
}else{
[receiveStatusDic setValue:@"-1"forKey:@"status"];
}
}else{
[receiveStatusDic setValue:@"-1"forKey:@"status"];
}
[selfperformSelectorOnMainThread:@selector(receiveData:)withObject:receiveStatusDicwaitUntilDone:NO];
}];
}
-(void)receiveData:(id)sender
{
NSLog(@"receiveData=%@",sender);
//从字典中取出AppStore中的版本号
NSDictionary *dic = [NSJSONSerializationJSONObjectWithData:senderoptions:NSJSONReadingMutableLeaveserror:nil];
NSString *version = [dicobjectForKey:@"version"];
}
//获取当前项目的版本号
NSDictionary *infoDictionary = [[NSBundlemainBundle]infoDictionary];
CFShow((__bridgeCFTypeRef)(infoDictionary));
NSString *app_Version = [infoDictionaryobjectForKey:@"CFBundleShortVersionString"];
//打开AppStore
NSString *str = [NSString stringWithFormat:@"http://itunes.apple.com/us/app/id%@",@1063983037];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];