ASIHTTPRequest的使用方法
来源:互联网 发布:国安网络长沙服务热线 编辑:程序博客网 时间:2024/06/05 23:37
ASIHTTPRequest 作为一款优秀的开源库,包括了普通的http请求,带cache功能,还支持请求队列,数据流,以及数据的压缩。 本文介绍 ASIHTTPRequest的最常用也是最简单的一部分使用方法, 使用它来下载一张图片
ASIHTTPRequest *httpRequest = [ASIHTTPRequest requestWithURL:url]; //根据url创建请求
//通过一个block来实现完成功能回调 [httpRequest setCompletionBlock:^{ [loadingView hide:YES];
UIImage *downloadedImage = [UIImage imageWithData:[httpRequest responseData]];//展示图片imageView.image = downloadedImage; }];
//通过block来实现接受数据的过程使用[httpRequest setBytesReceivedBlock:^(unsigned long long size, unsigned long long total){ NSLog(@"size:%lld,total:%lld",size,total); downloadedBytes += size; CGFloat progressPercent = (CGFloat)downloadedBytes/total; loadingView.progress = progressPercent; progressViewYellow.progress = progressPercent; progressLabel.text = [NSString stringWithFormat:@"%.0f%%",progressPercent*100]; }];
[httpRequest startSynchronous]; //使用同步方式请求,这会在主线程中进行
[httpRequest startAsynchronous]; //使用异步方式请求,推荐
- ASIHTTPRequest的使用方法
- ASIHTTPRequest的使用方法
- ASIHttpRequest——接收的使用方法
- ASIHttpRequest——接收的使用方法
- ASIHTTPRequest详细介绍,使用方法
- ios ASIHttpRequest库进行DELETE操作时delete带有参数表单的使用方法
- ASIHTTPRequest-Cookie的使用
- ASIHTTPRequest-Cookie的使用
- ASIHTTPRequest-Cookie的使用
- ASIHTTPRequest的使用
- ASIHttpRequest的使用
- ASIHTTPRequest库的添加
- ASIHTTPRequest的使用
- ASIHTTPRequest 的介绍
- ios的ASIHTTPRequest学习
- ASIHTTPRequest迟到的结果
- ASIHTTPRequest-插件的使用
- ASIHTTPRequest-Cookie的使用
- webkit webApp 开发技术要点总结
- mysql buffer pool里的三种链表和三种page
- 2.9.2 资源2.9.3 确定文本是A N S I文本还是U n i c o d e文本
- upstart 和ubuntu启动过程原理介绍 (转载)
- 经常问的2--php
- ASIHTTPRequest的使用方法
- MFC关键技术应用:动态创建
- 细说业务逻辑(前篇)
- java程序员必知的8大排序
- vim 替换命令总结
- c#如何扩展类型的内置方法
- css 控制input输入框不能输入中文
- Linux下面经常用到的几个命令
- linux sudo 命令