Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the AFNetworking 2.0 Equivalent to cancel operations

I used to be able to use cancelAllHTTPOperationsWithMethod: on the AFHTTPClient class to cancel operations. What is the new method to cancel operations?

like image 616
Piotr Tomasik Avatar asked Oct 07 '13 23:10

Piotr Tomasik


1 Answers

You can cancel operations manually. You can get the operations from the operation queue:

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 also have an operationQueue property if you're more into NSURLSession.

like image 88
Marcelo Fabri Avatar answered Nov 04 '22 01:11

Marcelo Fabri