ASIHttpRequest常用方法
来源:互联网 发布:flv.js 编辑:程序博客网 时间:2024/06/04 18:10
第一、根据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基础之集合框架(Collection 和 Map)
- nginx快速部署与perl支持
- MAC下安装与配置MySQL
- ASIHttpRequest常用方法
- JSON.stringify与jQuery.parseJSON
- 算法导论 雇用问题的随机算法 PERMUTE-BY-SORTING(c语言)
- 【shell命令】拆分、合并、排序、比较文件
- uva 10081 - Tight Words(dp)
- TFS - 换主板 重布署
- js中全部替换
- mac系统下,momo支持中文
- Linux下SHELL的PS1变量简介