这是我用来取消下载的代码。
NSArray *queueArray = [downloadQueue operations];
for (ASIHTTPRequest *request in queueArray) {
NSString *objid = [request.userInfo objectForKey:Column_objectid];
if ([objid isEqualToString:audioToDelete.objectId]) {
[request clearDelegatesAndCancel];
[request removeTemporaryDownloadFile];
...}}
但在我打电话之后 [请求clearDelegatesAndCancel]
downloadQueue.operations或downloadQueue.requestsCount仍然是相同的数量(downloadQueue是我的ASINetworkQueue)
如何从队列中删除它? 或者我怎样才能获得downloadQueue的正确操作次数?
答案 0 :(得分:2)
这样做:
NSArray *queueArray = [downloadQueue operations];
for (ASIHTTPRequest *request in queueArray) {
NSString *objid = [request.userInfo objectForKey:Column_objectid];
if ([objid isEqualToString:audioToDelete.objectId]) {
[request cancel];
}
}