How to cancel network request with afnetworking

Posted by Jason Zhao on Stack Overflow See other posts from Stack Overflow or by Jason Zhao
Published on 2012-06-17T09:11:02Z Indexed on 2012/06/17 9:16 UTC
Read the original article Hit count: 874

Filed under:

Is there a way to cancel all network request (the request started by another method) before I do a network request with AFNetworking I tried like below:

- (void)sendRequest:(NSUInteger)page{


NSURL *aUrl = [NSURL URLWithString:@"http://www.abc.com/"];
AFHTTPClient *httpClientToCancel = [[AFHTTPClient alloc] initWithBaseURL:aUrl];
[httpClientToCancel cancelAllHTTPOperationsWithMethod:@"POST" path:@"product/like"];
[httpClientToCancel release];

... start a new request here .....

But not work. I just want to cancel all request (at least the request I wrote above) before I start a new request.

Thank you!

© Stack Overflow or respective owner

Related posts about afnetworking