我使用 ASINetworkQueue 发送两个请求,它们在队列中。我的问题是,当请求失败/完成时我无法接收通知。
代码:
[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 被调用。