Question

I am using ASIHTTP request in my app where i am firing multiple request at a time. I want to cancel all the pending requests if any fails to get data. I am not using operation queue as im sending requests from a table view on tableview scroll. How to cancel rest pending requests without affecting the successfully completed requests? even if you are not using NSOperationQueue or ASIHTTPOperationQueue.

Was it helpful?

Solution

I am assuming you are talking about canceling asynchronous ASIHTTPRequest?

To cancel an asynchronous request i.e. a request that was started with [request startAsynchronous] call [request cancel].

Btw, by canceling a request ASIHTTPRequest treats it as an error and will call your delegate's failure method. If you do not want this behaviour, set your delegate to nil before calling cancel, or use the clearDelegatesAndCancel method instead. like so -

// Cancels an asynchronous request
[request cancel]

// Cancels an asynchronous request, clearing all delegates and blocks first
[request clearDelegatesAndCancel];

But since you are talking about multiple requests, I would suggest you use a queue. Canceling requests could then be done in one shot using [queue cancelAllOperations];.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top