title: AFNetworking 2.0 : AFHTTPRequestOperationManager asynchronous methode invoke
body: <p>I am using AFNetworking 2.0 for networking of my application, I have implemented a method to check the login of a user </p>
  
  <pre><code>-(NSString *) loginWith : (NSString *) email andPassword :(NSString *) password
  {
      __block NSString * result ;
  
      AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
  
      NSDictionary *params = @{@"email": email, @"password": password};
  
      manager.responseSerializer = [AFJSONResponseSerializer serializer];
  
      [manager POST:[kROOT_URL stringByAppendingString:@"auth/"] parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject)
      {
          NSLog(@"JSON: %@", (NSDictionary*)responseObject);
  
          [[NSUserDefaults standardUserDefaults] setObject:responseObject forKey:USER_KEY];
          [[NSUserDefaults standardUserDefaults] synchronize];
  
          result = [responseObject objectForKey:@"id"];
          NSLog(@"result :: %@",result);
  
      } failure:^(AFHTTPRequestOperation *operation, NSError *error)
      {
          NSLog(@"Error: %@", error);
  
          result = nil;
  
      }];
  
      return result;
  }
  </code></pre>
  
  <p>and from other view controller I am invoking this method :</p>
  
  <pre><code>NSString * result = [self.user loginWith:emailCell.textField.text andPassword:passCell.textField.text];
  
  NSLog(@"Result: %@",result);
  </code></pre>
  
  <p>the problem is that I get "null" as the object of result, This is because that when the NSlog is executed the network process was doing in background thread, so how I correct the implementation, so then I can get the result in the right moment, after fetching</p>
  
  <p>Thank you</p>