AFNetworking 2.0中取消操作的等效方法是什么?

7

我曾经可以在AFHTTPClient类上使用cancelAllHTTPOperationsWithMethod:来取消操作。现在取消操作的新方法是什么?

1个回答

21
您可以手动取消操作。您可以从操作队列中获取这些操作:


AFHTTPRequestOperationManager *manager = // ...
for (NSOperation *operation in manager.operationQueue.operations) {
 // here you can check if this is an operation you want to cancel
    [operation cancel];
}

// or just cancel all of them!
[manager.operationQueue cancelAllOperations];

AFURLSessionManager还拥有一个operationQueue属性,如果您更喜欢NSURLSession


1
据我所知,RequestOperation适用于iOS 6+,而SessionManager适用于iOS 7+。 - Piotr Tomasik
它们都使用操作的概念。您只需要从您正在使用的对象中获取它们。 - Marcelo

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接