1
我使用ASINetworkQueue发送两个请求,这两个请求位于队列中。 我的问题是,当 请求失败/完成时,我无法收到通知。ASIHTTPRequest:在网络队列中接收来自几个请求的代理
代码:
[networkQueue cancelAllOperations];
[networkQueue setShowAccurateProgress:YES];
[networkQueue setUploadProgressDelegate:self.progressIndicator];
[networkQueue setDelegate:self];
[networkQueue setQueueDidFinishSelector:@selector(queueDidFinish)];
NSURL *urlAttachment = [NSURL URLWithString:@"http://localhost/test1.xml"]];
ASIFormDataRequest *requestFile = [[[ASIFormDataRequest alloc] initWithURL:urlAttachment] autorelease];
[requestFile setFile:filePath forKey:@"attachment[test]"];
[requestFile setDidFailSelector:@selector(test1WentWrong)];
[requestFile setDidFinishSelector:@selector(test1Done)];
[networkQueue addOperation:requestFile]; //queue is an NSOperationQueue
NSURL *url = [NSURL URLWithString:@"http://localhost/test2.xml"]];
ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease];
[request setPostValue:test.filename forKey:@"filename[test]" ];
[request setDidFailSelector:@selector(test2WentWrong)];
[request setDidFinishSelector:@selector(test2Done)];
[networkQueue addOperation:request]; //queue is an NSOperationQueue
[networkQueue go];
test1WentWrong,test1Done,test2WentWrong,test2Done不叫。 尽管请求运行良好,并且queueDidFinish被调用。
本,非常感谢您的回答。我失明了;-)添加委托完美运作。感谢你提供如ASIHTTPRequest这样的包装。这是非常好的,方便使用。我喜欢。 – Stefan 2009-06-27 07:50:32