Ios – Add operation in queue while requesting ASIHTTPRequest or AFNetworking

afnetworkingasihttprequestiosobjective c

I want to add operation into executing request. I read about ASINetworkQueue, but it adds all operation and run it all. but i want to add operation into running queue.

Is this possible? using ASIHTTPRequest or AFNetworking i don't mind, as long as i get what i intend to do.

EDIT

It shows below error while i try to add another request.

[ASINetworkQueue addOperation:]: operation is executing and cannot be enqueued'

Best Answer

From the apple documentation for addOperation: it is clear that you cannot add an operation which is executing into a NSOperationQueue.

This is what mentioned there,

An operation object can be in at most one operation queue at a time and this method throws an NSInvalidArgumentException exception if the operation is already in another queue. Similarly, this method throws an NSInvalidArgumentException exception if the operation is currently executing or has already finished executing.

That is the default behavior of NSOperationQueue. You need to make sure that the NSOperation is not executing before adding to queue. There are various properties such as isExecuting, isFinished etc.. to check this.