title: How to chain multiple AFNetworking calls to each run after the previous has finished successfully?
body: <p>The following method uses AFNetworking to send a request to a webservice and (when successful) acts upon the response. AFNetworking does the request asynchronously and uses blocks for success or failure. So the method to send the request looks something like this (simplified):</p>
  
  <pre><code>- (void)sendRequestForConnector:(NSString *)connector 
            success:(void (^)(NSData *responseXml))success
            failure:(void (^)(NSError *error))failure
  {
    AFHTTPRequestOperation *operation = [self HTTPRequestOperationForConnector:connector];
    [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) 
    {
      [self handleSuccessForConnector:connector response:[operation responseData]];
      success([operation responseData]);
    } 
    failure:^(AFHTTPRequestOperation *operation, NSError *error) 
    {
      [self handleFailureForConnector:connector error:error];
      failure(error);
    }
  
    [operation start];
  }
  </code></pre>
  
  <p>In another class this method is used to call the webservice multiple times. When the previous call was successful, the next call is done. This method looks something like this (failure blocks omitted for brevity):</p>
  
  <pre><code>- (void)import 
  {
     [client sendRequestForConnector:@"cities" success:^{
       [client sendRequestForConnector:@"categories" success:^{
         [client sendRequestForConnector:@"categoryTranslations" success:^{
           [client sendRequestForConnector:@"products" success:^{
             [client sendRequestForConnector:@"productTranslations" success:^{
  
               [self finishImport];
  
             }];
           }];
         }]; 
       }];
     }];
  }
  </code></pre>
  
  <p>This works, but as one can see, each webservice call adds another nested success block handler. It seems to me there must be a nicer way to do this, but I can't think of one. </p>
  
  <p>Preferably, I want to wait for the previous call to be completed before I do the next call and use something like GCD to call the whole import method asynchronously. However, AFNetworking is not designed to make synchronous calls.</p>
  
  <p>Any ideas how to achieve this are greatly welcomed. Or is my current solution the way to go?</p>