【问题标题】:how can i remove request from ASINetworkQueue如何从 ASINetworkQueue 中删除请求
【发布时间】:2012-10-04 03:59:26
【问题描述】:

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

    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)

如何将其从队列中移除? 或者我怎样才能得到我的下载队列的正确操作计数?

【问题讨论】:

  • 尽管队列数相同,但在 clearDelegatesAndCancel 调用之后,请求是否实际被处理???

标签: iphone objective-c ios ipad asihttprequest


【解决方案1】:

这样做:

NSArray *queueArray =  [downloadQueue operations];
for (ASIHTTPRequest *request in queueArray) {
    NSString *objid = [request.userInfo objectForKey:Column_objectid];
    if ([objid isEqualToString:audioToDelete.objectId]) {
        [request cancel];
    }
 }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多