如何从ASINetworkQueue中删除请求

时间:2012-10-04 03:59:27

标签: iphone objective-c ios ipad asihttprequest

这是我用来取消下载的代码。

    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的正确操作次数?

1 个答案:

答案 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];
    }
 }