ASIHttpRequest常用方法
来源:互联网 发布:单片机1ms延时程序 编辑:程序博客网 时间:2024/05/17 02:52
http://www.open-open.com/lib/view/open1383738977305.html
第一、根据url创建请求
ASIHTTPRequest *httpRequest = [ASIHTTPRequest requestWithURL:url];
第二、设置请求的方法
[httpRequest setRequestMethod:@"GET"];
第三、设置最大连接超时时间
[httpRequest setTimeOutSeconds:60];
第四、代理方法表示请求成功
- (void)requestFinished:(ASIHTTPRequest *)request
{
UIImage *image=[UIImage imageWithData:request.responseData];
self.image=image;
}
第五、代理方法表示请求失败
- (void)requestFailed:(ASIHTTPRequest *)request
{
NSError *error=request.error;
NSLog(@"请求出错:%@",error);
}
第六、通过block设置请求失败
[httpRequest setFailedBlock:^{
NSError *error=httpRequest.error;
NSLog(@"请求出 错:%@",error);
}];
第七、通过一个block来实现完成功能回调
[httpRequest setCompletionBlock:^{
[loadingView hide:YES];
第八、ios 4以上,是否开启后台执行
[httpRequest setShouldContinueWhenAppEntersBackground:YES];第九 设置超时自动重传
[httpRequest setNumberOfTimesToRetryOnTimeout:2];
第十、获取cookies
NSMutableArray *cookie=[httpRequest requestCookies];
第十一、清除cookies
[ASIHTTPRequest clearSession];
第十二、设置cookie
[ASIHTTPRequest setSessionCookies:cookie];
第十三、当前网络是否可用
[ASIHTTPRequest isNetworkInUse];
第十四、判断是否为2G/3G
[ASIHTTPRequest isNetworkReachableViaWWAN];
第十五、网络请求时,关闭状态显示栏的loading
[ASIHTTPRequest setShouldUpdateNetworkActivityIndicator:NO];
- ASIHttpRequest常用方法
- ASIHttpRequest常用方法
- ASIHttpRequest常用方法
- ASIHttpRequest常用方法
- ASIHTTPRequest清除keyChain方法
- ASIHTTPRequest發送異步請求方法之一
- IOS 常用开源包 之 ASIHTTPRequest
- ASIHTTPRequest拓展UIImageView的方法
- ASIHTTPRequest
- ASIHTTPRequest
- ASIHTTPRequest
- ASIHTTPRequest
- ASIHTTPRequest
- ASIHTTPRequest
- ASIHTTPRequest
- asihttprequest
- ASIHTTPRequest
- ASIHTTPRequest
- Java web自定义标签按钮级别权限控制完美诠释(jplogic 快速开发平台)
- ASIHttpRequest的一个Bug与30秒超时
- iOS经验1:自己写的网络数据请求 第三方框架 断点续传 上传下载
- 安卓基础巩固
- Angular离线API文档安装指南
- ASIHttpRequest常用方法
- 获取java线程中信息的两种方法
- 解析Cloudera Manager内部结构、功能包括配置文件、目录位置等
- Drools规则工作流引擎开发视频教程
- MyEclipse6.5启动后 自动关闭 jvm terminated. exit code=1
- pascal大牛请进
- 在资源管理器中快捷访问FTP服务器
- 色彩基础理论
- 从实践中学习Android——ListView下拉刷新(上——实现listView列表)