有关ASINetworkQueues的问题
来源:互联网 发布:网络培训的意义 编辑:程序博客网 时间:2024/06/05 22:38
根据这个链接里的例子 https://gist.github.com/150447
- (void)doNetworkOperations
{
// Stop anything already in the queue before removing it
[[self networkQueue] cancelAllOperations];
// Creating a new queue each time we use it means we don't have to worry about clearing delegates or resetting progress tracking
[self setNetworkQueue:[ASINetworkQueue queue]];
[[self networkQueue] setDelegate:self];
[[self networkQueue] setRequestDidFinishSelector:@selector(requestFinished:)];
[[self networkQueue] setRequestDidFailSelector:@selector(requestFailed:)];
[[self networkQueue] setQueueDidFinishSelector:@selector(queueFinished:)];
int i;
for (i=0; i<5; i++) {
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com"]];
[[self networkQueue] addOperation:request];
}
[[self networkQueue] go];
}
- (void)requestFinished:(ASIHTTPRequest *)request
{
// You could release the queue here if you wanted
if ([[self networkQueue] requestsCount] == 0) {
// Since this is a retained property, setting it to nil will release it
// This is the safest way to handle releasing things - most of the time you only ever need to release in your accessors
// And if you an Objective-C 2.0 property for the queue (as in this example) the accessor is generated automatically for you
[self setNetworkQueue:nil];
}
//... Handle success
NSLog(@"Request finished");
}
我在for循环里添加不了各不相同的请求, 因为要对各个请求返回的数据进行操作,在requestFinished方法里该怎么去区分事件呢?
// Custom user information associated with the request (not sent to the server)
NSDictionary *userInfo;
- (void)doNetworkOperations
{
// Stop anything already in the queue before removing it
[[self networkQueue] cancelAllOperations];
// Creating a new queue each time we use it means we don't have to worry about clearing delegates or resetting progress tracking
[self setNetworkQueue:[ASINetworkQueue queue]];
[[self networkQueue] setDelegate:self];
[[self networkQueue] setRequestDidFinishSelector:@selector(requestFinished:)];
[[self networkQueue] setRequestDidFailSelector:@selector(requestFailed:)];
[[self networkQueue] setQueueDidFinishSelector:@selector(queueFinished:)];
int i;
for (i=0; i<5; i++) {
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com"]];
[[self networkQueue] addOperation:request];
}
[[self networkQueue] go];
}
- (void)requestFinished:(ASIHTTPRequest *)request
{
// You could release the queue here if you wanted
if ([[self networkQueue] requestsCount] == 0) {
// Since this is a retained property, setting it to nil will release it
// This is the safest way to handle releasing things - most of the time you only ever need to release in your accessors
// And if you an Objective-C 2.0 property for the queue (as in this example) the accessor is generated automatically for you
[self setNetworkQueue:nil];
}
//... Handle success
NSLog(@"Request finished");
}
我在for循环里添加不了各不相同的请求, 因为要对各个请求返回的数据进行操作,在requestFinished方法里该怎么去区分事件呢?
// Custom user information associated with the request (not sent to the server)
NSDictionary *userInfo;
- 有关ASINetworkQueues的问题
- 关于 ASINetworkQueues
- 有关JBoss的问题
- 有关网上邻居的问题
- 有关网上邻居的问题
- 有关MMU的问题!
- 有关随机数的问题
- 有关编译的问题
- 有关博弈的问题
- 有关fsockopen()的问题
- 有关预处理的问题
- 有关DirectSoundFullDuplexCreate8的问题
- 有关sizeof的问题
- 有关内存的问题
- 有关同步的问题
- 有关var_list的问题
- 有关数据库的问题
- 有关域名的问题
- Android Listview 加载图片优化--本地加载大量图片,解决滑动卡顿现象(滑动停止加载图片)
- Wireshark的NPF driver,There are no interfaces on which a capture can be done 问题
- 在表格菜单中,用JavaScript实现随着鼠标的滚动改变行的颜色
- vs 文本文字的一些设置
- 图片搜索初探
- 有关ASINetworkQueues的问题
- 如何在C、C++中动态分配二维数组
- svn 命令总结
- 【转】Android ANR分析
- Oracle SQL的优化规则:
- x264_macroblock_cache_init 的分析
- 提高班教给我的
- ZC702开发板简介
- GDI 绘图之 BitBlt 用法