ios检测版本更新代码
2014-01-21 10:16
316 查看
-(void)GetUpdate
{
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
NSString *nowVersion = [infoDict objectForKey:@"CFBundleVersion"];
NSURL *url = [NSURL URLWithString:@"http://itunes.apple.com/lookup?id=***"];
NSString * file = [NSString stringWithContentsOfURL:url];
NSLog(file);
//"version":"1.0"
NSRange substr = [file rangeOfString:@"\"version\":\""];
NSRange substr2 =[file rangeOfString:@"\"" options:NULL range:NSRange{substr.location+substr.length,10}];
NSRange range = {substr.location+substr.length,substr2.location-substr.location-substr.length};
NSString *newVersion =[file substringWithRange:range];
if([nowVersion isEqualToString:newVersion]==NO)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"版本有更新" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"更新", nil];
[alert show]; www.2cto.com
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex==1)
{
NSURL *url = [NSURL URLWithString:@"https://itunes.apple.com/us/app/qun-xiang-dao/id***?ls=1&mt=8"];
[[UIApplication sharedApplication]openURL:url];
}
}
{
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
NSString *nowVersion = [infoDict objectForKey:@"CFBundleVersion"];
NSURL *url = [NSURL URLWithString:@"http://itunes.apple.com/lookup?id=***"];
NSString * file = [NSString stringWithContentsOfURL:url];
NSLog(file);
//"version":"1.0"
NSRange substr = [file rangeOfString:@"\"version\":\""];
NSRange substr2 =[file rangeOfString:@"\"" options:NULL range:NSRange{substr.location+substr.length,10}];
NSRange range = {substr.location+substr.length,substr2.location-substr.location-substr.length};
NSString *newVersion =[file substringWithRange:range];
if([nowVersion isEqualToString:newVersion]==NO)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"版本有更新" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"更新", nil];
[alert show]; www.2cto.com
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex==1)
{
NSURL *url = [NSURL URLWithString:@"https://itunes.apple.com/us/app/qun-xiang-dao/id***?ls=1&mt=8"];
[[UIApplication sharedApplication]openURL:url];
}
}
相关文章推荐
- iOS 检测版本更新
- iOS 版本更新(强制更新)检测问题
- iOS开发 检测版本更新
- iOS --检测更新版本
- ionic 检测版本更新,Android版,IOS在浏览器打开下载页面。
- iOS通过iTunes search检测版本更新,并提示用户更新!
- iOS APP如何实现版本检测更新
- iOS版本检测更新
- iOS应用版本更新(自动提醒用户更新代码)
- iOS 检测版本更新
- ios检测版本更新
- iOS通过iTunes search检测版本更新,并提示用户更新!
- iOS 检测版本更新
- iOS通过iTunes search检测版本更新,并提示用户更新!
- iOS 应用版本检测更新
- iOS 检测版本更新
- iOS 检测版本更新
- iOS通过iTunes search检测版本更新,并提示用户更新
- iOS 检测版本更新
- IOS检测版本更新