-(void)appVersion{ //self.appUrlInAppStore爲應用在AppStore的完整url地址 if (!self.appUrlInAppStore) { return ; } NSURL *url = [NSURL URLWithString:self.appUrlInAppStore]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [NSURLConnection connectionWithRequest:request delegate:self]; } -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{ NSError *error; id response = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error]; NSDictionary *appInfo = (NSDictionary *)response; NSArray *infoContent = appInfo[@"results"]; //最新版本號 NSString *newestVersion = [infoContent[0] objectForKey:@"version"]; NSLog(@"最新的版本號:%@",newestVersion); //獲取當前版本號 NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary]; NSString *currentAppVersion = infoDic[@"CFBundleShortVersionString"]; NSLog(@"app如今的版本號:%@",currentAppVersion); //根據兩個版本號是否是一致去提示用戶升級 }