title: AFnetworking waitUntilFinish not working
body: <p>I am making a project that uses the AFNetworking Library. I use it to check for a login and password with the webservice. This gives me a 200-code back if it is ok. If it is 200, I set a boolean to true so that the application can continue. But this boolean is not set at the right time. I always need to press two times on my <code>login button</code> before it works. Here is my code to set the boolean.</p>
  
  <pre><code>    - (BOOL)credentialsValidated {
      self.progressHUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
      self.progressHUD.labelText = @"Loading";
      self.progressHUD.mode = MBProgressHUDModeIndeterminate;
      self.progressHUD.dimBackground = YES;
       [[API sharedInstance] loginCommand:[NSMutableDictionary dictionaryWithObjectsAndKeys:_txtLogin.text,@"email",_txtPass.text,@"pwd", nil] onCompletion:^(NSDictionary *json){
       //completion
           if(![json objectForKey:@"error"]){
               NSLog(@"status %@",[json valueForKeyPath:@"data.status"]);
               if([[json valueForKeyPath:@"data.status"]intValue] == 200){
                  //Create user object
  
  
                  _loginstatus =  YES;
                  [self.progressHUD hide:YES afterDelay:5];
               }else{
                   //show validation
                   _txtLogin.text = @"";
                   _txtPass.text = @"";
                   _loginstatus = NO;
               }
           }else {
               NSLog(@"Cannot connect to the server");
           }
       }];
       if(_loginstatus){
           NSLog(@"true");
      }else{
          NSLog(@"false");
      }
      [self.progressHUD hide:YES afterDelay:5];
       return _loginstatus;
  }
  </code></pre>
  
  <p>And here is my API code.</p>
  
  <pre><code>-(void)loginCommand:(NSMutableDictionary *)params onCompletion:(JSONResponseBlock)completionBlock{
      NSLog(@"%@%@",kAPIHost,kAPILogin);
      NSMutableURLRequest *apiRequest = [self multipartFormRequestWithMethod:@"POST" path:kAPILogin parameters:params constructingBodyWithBlock:^(id &lt;AFMultipartFormData&gt;formData){
          //TODO: attach file if needed
  
      }];
      AFJSONRequestOperation *operation = [[AFJSONRequestOperation alloc] initWithRequest:apiRequest];
      [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject){
          //success !
          NSLog(@"SUCCESSSS!");
          completionBlock(responseObject);
      }failure:^(AFHTTPRequestOperation *operation, NSError *error){
          //Failure
          NSLog(@"FAILUREE!");
          completionBlock([NSDictionary dictionaryWithObject:[error localizedDescription] forKey:@"error"]);
      }];
      [operation start];
  
  }
  </code></pre>
  
  <p>When I put below <code>[operation start]</code> the <code>[operation waitUntilFinish]</code> code, the app crashes. </p>
  
  <p>Can somebody help me with this?</p>
  
  <p>Kind regards</p>
  
  <p><strong>LOG</strong>
  Here is a print of my log <strong>after I 2 two times</strong> pressed the login button</p>
  
  <pre><code>2012-12-28 09:36:00.547 Offitel[6532:907] http://virtuele-receptie.******.sanmax.be/nl/webservice/company-user/****/*****/**************
  2012-12-28 09:36:00.561 Offitel[6532:907] false
  2012-12-28 09:36:01.604 Offitel[6532:907] SUCCESSSS!
  2012-12-28 09:36:01.605 Offitel[6532:907] status 200
  2012-12-28 09:36:20.742 Offitel[6532:907] aanmelden pressed
  2012-12-28 09:36:20.746 Offitel[6532:907] http://virtuele-receptie.******.sanmax.be/nl/webservice/company-user/****/*****/**************
  2012-12-28 09:36:20.748 Offitel[6532:907] true
  2012-12-28 09:36:22.184 Offitel[6532:907] SUCCESSSS!
  2012-12-28 09:36:22.184 Offitel[6532:907] status 200
  </code></pre>