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