I had a play around and the ended up implement my own completion block and failure block so they can be executed on the some thread as the request operation by adding a category to the AFHTTPRequestOperation class
- (void)startAndWaitWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{
[self start];
[super waitUntilFinished];
id responseObject = self.responseObject; // need this line for AFNetworking to create error;
if (self.error) {
if (failure) failure(self, self.error);
} else {
if (success) success(self, responseObject);
}
}
The operation will start then block the thread till the operation is completed. Then depend on success or failure, call the corresponding block before finish the operation.
This way i can chain multiple request operation one after another and the completion block will have the processed data from the previous request completion block