asihttprequest简单异步
2011-12-22 17:30
281 查看
调试环境:
ASIHTTPRequest版本1.8.1-61 2011-9-19修复版
Xcode版本4.2.1
iOS5.0
Mac OS X10.7.1
在此代码仅仅捣鼓异步的初步处理
1、需要实现协议接口
ASIHTTPRequestDelegate
主要requestFailed,requestFinished之类的接口
2、调用的时候,建议启动异步request的对象和异步处理的对象分开定义
下面我的代码是启动异步和异步处理定义在一起
代码:
在使用中,我把AsynBaseDeal对象定义为UIApplication层面的成员变量来用的,这样避免了在异步处理结束前就释放了对应的处理对象
ASIHTTPRequest版本1.8.1-61 2011-9-19修复版
Xcode版本4.2.1
iOS5.0
Mac OS X10.7.1
在此代码仅仅捣鼓异步的初步处理
1、需要实现协议接口
ASIHTTPRequestDelegate
主要requestFailed,requestFinished之类的接口
2、调用的时候,建议启动异步request的对象和异步处理的对象分开定义
下面我的代码是启动异步和异步处理定义在一起
代码:
@interface AsynBaseDeal : NSObject<ASIHTTPRequestDelegate> - (void)LoadImage:(NSString *)strUrl; @end
@implementation AsynBaseDeal - (id)init { self = [super init]; if (self) { } return self; } - (void)dealloc { [super dealloc]; } - (void)LoadImage:(NSString *)strUrl { if (strUrl) { ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:strUrl]]; [request setDelegate:self]; [request startAsynchronous]; } } - (void)requestFailed:(ASIHTTPRequest *)request { NSLog(@"error :%@" ,[request error]); } - (void)requestFinished:(ASIHTTPRequest *)request { NSLog(@"finish :%@ ,%d" ,[request responseData] ,request.responseEncoding); } @end
在使用中,我把AsynBaseDeal对象定义为UIApplication层面的成员变量来用的,这样避免了在异步处理结束前就释放了对应的处理对象
相关文章推荐
- asihttprequest简单异步
- 【IOS】利用ASIHTTPRequest 实现一个简单的登陆验证
- iOS用ASIHttpRequest进行异步请求
- ASIHTTPRequest发送异步GET请求
- iOS网络编程-ASIHTTPRequest异步请求
- ASIHTTPRequest系列(一):同步和异步请求
- ASIHTTPRequest系列(1):同步和异步请求
- ios 使用ASIHTTPRequest异步读取远程txt文件
- ASIHTTPRequest的简单使用
- asihttprequest下载例子,集进度条和字节数显示,多线程异步下载,断点续传,解压缩
- ASIHTTPRequest系列(一):同步和异步请求
- ASIHTTPRequest源码简单分析
- IOS网络通信 之第三方框架ASIHttpRequest的简单使用
- ASIHTTPRequest系列(一):同步和异步请求
- IOS 学习笔记 —— ASIHTTPRequest 之 发送异步请求
- iOS总结:ASIHttpRequest类库发送请求(同步请求和异步请求)
- iOS网络编程-ASIHTTPRequest异步请求
- 【IOS】利用ASIHTTPRequest 实现一个简单的登陆验证
- ASIHttpRequest简单用法
- IOS学习十四:网络之ASIHttpRequest和SBJson简单使用