I need to perform a series of server calls that run sequentially and where one request can only be executed if all previous requests have been successful.
So, my idea was to create an AFHTTPRequestOperation
for each request and use [myAFHTTPClient enqueueBatchOfHTTPRequestOperations:]
to fire them off.
I can make them run sequentially by calling
[myAFHTTPClient.operationQueue setMaxConcurrentOperationCount:1]
But how can I make sure that the remaining operations run only if the previous operations were successfull?
I tried to create a completionBlock
for every operation that calls [myAFHTTPClient cancelAllOperations]
in case the operation failed, but the completionBlock and the next operation in the queue run concurrently, so the next request could already be sent to the server before it gets cancelled. What should I do?