-2

Here's my code :

[[AFNetworkReachabilityManager sharedManager] startMonitoring];
mainManager = [AFHTTPRequestOperationManager manager];
mainManager.requestSerializer.timeoutInterval = 30;

I initialise my AFHTTPRequestOperationManager like this.

urlToWhere = @"myurl.php";
parameters = @{@"user_id": "1"};
NSLog(@"a"); 
[mainManager POST:urlToWhere parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"result");
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"error");
}];
NSLog(@"b");

The fact is my a is display in the logs, but none of "result" or "error" are displayed, and then the b is displayed.

Is there any exception where the AFHTTPRequestOperationManager would be dodge ?

  • 1
    Result and Error will only be called once the response is received or an error occurred. How big do you expect the response to be? The POST method is a block in a background thread and won't show immediately. – emotality Apr 29 '15 at 14:12
  • I would like my code to wait for the answer before going on, so I had `dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); mainManager.completionQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);` in front of it, and `dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);` at the end. still doesn't work – Vincent 'On-arap' Burel Apr 29 '15 at 15:17
  • `urlToWhere` is not a valid URL. That's why this doesn't work. – mattt May 07 '15 at 13:58

1 Answers1

0

I can not comment at the moment, so using the answer options. shouldn't your urlToWhere parameter like this

urlToWhere = @"http://myurl.php";
Qazi
  • 381
  • 2
  • 8