我刚刚开始测试我已构建的一些上传工具,并上传了47个项目,但队列在第15或第18或第21项随机停止,不确定原因,但选择器被过早调用虽然并非所有请求都结束了。
我所做的唯一特别的事情就是将maxconcurrent请求提高到6而不是4,但是 这似乎不是一个大问题。
我按如下方式配置选择器:
[self.uploadQueue setDelegate: self];
[self.uploadQueue cancelAllOperations];
[self.uploadQueue setRequestDidStartSelector: @selector(uploadRequestStarted:)];
[self.uploadQueue setRequestDidFinishSelector:@selector(uploadRequestEnded:)];
[self.uploadQueue setQueueDidFinishSelector:@selector(uploadQueueEnded:)];
[self.uploadQueue setDownloadProgressDelegate: myProgress];
[self.uploadQueue showAccurateProgress];
这是我的日志:
2011-08-18 12:39:03.916 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView startUpload] Num requests: 47
2011-08-18 12:39:08.987 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #3 successfully!
2011-08-18 12:39:09.036 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #2 successfully!
2011-08-18 12:39:09.911 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #0 successfully!
2011-08-18 12:39:09.913 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #5 successfully!
2011-08-18 12:39:10.011 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #4 successfully!
2011-08-18 12:39:12.691 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #6 successfully!
2011-08-18 12:39:13.588 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #9 successfully!
2011-08-18 12:39:14.205 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #8 successfully!
2011-08-18 12:39:14.229 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #10 successfully!
2011-08-18 12:39:15.739 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #11 successfully!
2011-08-18 12:39:17.278 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #12 successfully!
2011-08-18 12:39:17.894 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #13 successfully!
2011-08-18 12:39:18.815 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #15 successfully!
2011-08-18 12:39:18.986 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #14 successfully!
2011-08-18 12:39:19.191 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadQueueEnded:] queue ended?
很想听到你的任何建议:) 提前致谢, 晒。
答案 0 :(得分:3)
您是否尝试过将setShouldCancelAllRequestsOnFailure:
设为NO
?如果任何单个请求失败,队列的默认行为是取消所有剩余请求。
可能是请求失败(由于某种原因)导致您的队列过早完成。