ios 使用ASIHTTPRequest来检查版本更新
- (void) alertWithTitle: (NSString *)_title_ msg:(NSString *)msg delegate:(id)_delegate cancelButtonTitle:(NSString*)_cancelTitle otherButtonTitles:(NSString*)_otherTitles{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:_title_
message:msg
delegate:_delegate
cancelButtonTitle:_cancelTitle
otherButtonTitles:_otherTitles,nil];
[alert show];
}
#pragma mark - update
-(void)checkUpdate{
MBKAppDelegate *mbkApp = (MBKAppDelegate *)[[UIApplication sharedApplication] delegate];
if (![mbkApp networkIsReach]) {
return;
}
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/lookup?id=%@",kAppId]];
ASIHTTPRequest *request =[ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request setDidFinishSelector:@selector(requestDone:)];
[request setDidFailSelector:@selector(requestWentWrong:)];
[request startSynchronous];
}
#pragma mark - asihttprequest
- (void)requestDone:(ASIHTTPRequest *)request
{
NSError *err = nil;
NSDictionary *dictionary =
[[CJSONDeserializer deserializer] deserializeAsDictionary:[request responseData] error:&err];
if (err != nil) {
[self failure];
return;
}
NSArray *a = [dictionary objectForKey:@"results"];
if (a.count == ) {
[self failure];
return;
}
NSDictionary *d = [a objectAtIndex:];
NSString *newVersion = [d objectForKey:@"version"];
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
NSString *nowVersion = [infoDict objectForKey:@"CFBundleVersion"];
NSString *msg = @"";
NSString *cancelTitle = @"";
NSString *otherTitles = @"";
if(![nowVersion isEqualToString:newVersion])
{
msg = @"版本有更新";
cancelTitle = @"取消";
otherTitles = @"更新";
}else{
msg = @"已经是最新版本啦";
cancelTitle = @"好";
otherTitles = nil;
}
[self alertWithTitle:nil msg:msg delegate:self cancelButtonTitle:cancelTitle otherButtonTitles:otherTitles];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if(buttonIndex==){
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://itunes.apple.com/us/app/qun-xiang-dao/id%@?ls=1&mt=8",kAppId]];
[[UIApplication sharedApplication]openURL:url];
}
}
- (void)requestWentWrong:(ASIHTTPRequest *)request
{
[self failure];
}
- (void)failure{
[self alertWithTitle:nil msg:@"检查失败了" delegate:self cancelButtonTitle:@"好" otherButtonTitles:nil];
}
转:http://my.oschina.net/brucezcq/blog/148905
ios 使用ASIHTTPRequest来检查版本更新的更多相关文章
- iOS - 利用 iTunes 接口检查 App 版本更新
iOS 想要检查 App 当前版本是否为最新,一般的方案大概都是服务器自己提供一个接口来获取 App 最新版本是多少,然后再做出相应提示是否需要更新,但是接口需要手动维护,应用要审核,还得等审核通过以 ...
- iOS子线程操作检测版本更新,有新版本通知用户更新, CheckVersion
iOS子线程操作检测版本更新,有新版本通知用户更新 CheckVersion 一:如何使用: #import "CheckVersion.h" //输入你的app在appStore ...
- ios检查版本更新
场景 在我们使用应用时,一打开应用,如果此应用有新的版本,常常能在应用中给出提示,是否要更新此应用.所以,我们就来看看,版本更新是如何实现的. 应用 苹果给了我们一个接口,能根据应用i ...
- iOS:ASIHttpRequest虽不更新,但仍值得详细了解
一.使用ASIHTTPRequest可以很方便的进行一下操作:同步/异步方式下载数据,定义下载队列,让队列中的任务按指定的并发数来下载(队列下载必须是异步的),提交表单,文件上传,处理cookie,设 ...
- iOS通过ASIHTTPRequest提交JSON数据
先验知识——什么是ASIHTTPRequest? 使用iOS SDK中的HTTP网络请求API,相当的复杂,调用很繁琐,ASIHTTPRequest就是一个对CFNetwork API进行了封装,并且 ...
- iOS用ASIHttpRequest上传
1.新建一个single view工程,导入ASIHttpRequest库,导入MobileCoreServices.CFNetwork.SystemConfiguration和libz1.2.5.d ...
- iOS学习——内存泄漏检查及原因分析
项目的代码很多,前两天老大突然跟我说项目中某一个ViewController的dealloc()方法没有被调用,存在内存泄漏问题,需要排查原因,解决内存泄漏问题.由于刚加入项目组不久,对出问题的模块的 ...
- ios中asihttprequest 下载缓存
asi中下载缓存第一种方法 #import <UIKit/UIKit.h> #import "ASIHTTPRequest.h" #import "ASIDo ...
- ios 的ASIHTTPRequest学习
发起一个同步请求 同步意为着线程阻塞,在主线程中使用此方法会使应用Hang住而不响应任何用户事件.所以,在应用程序设计时,大多被用在专门的子线程增加用户体验,或用异步请求代替(下面会讲到). - (I ...
随机推荐
- json格式在ruby和rails中的注意事项
#虚拟网络拓扑的json数据 def topodata #@vnic = Vnic.all #flash.now[:notice] = 'Message sent!' #flash.now[:aler ...
- 免费CA数字证书的申请、安装、导入、导出
http://wenku.baidu.com/link?url=oDUw50eCE5zX8tmg4N3-ddYGLt1U5aJYGEN7rk_z7t6LuMHL3M4oBstYBI_dQ1UnCtcK ...
- svn命令使用常见问题
1.如何添加文件 ? svn add filename svn ci -m "add file" 2. svn ci 出现冲突 经常多人开发时难免多个人修改同一个文件导致冲突发送, ...
- 数据库 Oracle数据库性能优化
--在Oacle数据库涉及到全表扫描的SQL查询(top,count)中, --现场用户删除表中大部分数据,只保留1W条数据,但是查询仍然很慢,检查磁盘IO,发现磁盘IO不是很高 --经过分析Oacl ...
- C# 在Bitmap上绘制文字出现锯齿的问题
解决锯齿问题主要是修改Graphics的属性 修复绘制图片锯齿问题可以修改 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiA ...
- Event Listener's Adapter Classes
摘自: http://www.ntu.edu.sg/home/ehchua/programming/java/J4a_GUI.html Refer to the WindowEventDemo, a ...
- 后序线索二叉树中查找结点*p的后继
在后序线索二叉树中查找结点*p的后继: 1.若结点*p为根,则无后继:2.若结点*p为其双亲的右孩子,则其后继为其双亲:3.若结点*p为其双亲的左孩子,且双亲无右子女,则其后继为其双亲:4.若结点*p ...
- Prime is problem - 素数环问题
题目描述: A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each ...
- c++获取cpu信息
原文地址:http://blog.csdn.net/jamesliulyc/article/details/2028958 1.什么是cpuid指令 CPUID指令是intel IA32架构下获得CP ...
- (转)fiddler模拟post请求
转自:https://www.cnblogs.com/xiaoxi-3-/p/7612254.html 前言: Fiddler是一个简单的http协议调试代理工具,它界面友好,易于操作,是模拟http ...