This is the entire code of my Foundation test app: (shrunk to the minimum possible)
#import <Foundation/Foundation.h>
#import "AFNetworking.h"
int main(int argc, const char * argv[]) {
@autoreleasepool {
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:@"http://www.ansa.it" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"success");
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"failure");
}];
// Trying both with -waitUntilAllOperationsAreFinished and with making the main thread sleep
[manager.operationQueue waitUntilAllOperationsAreFinished];
//[NSThread sleepForTimeInterval:5];
NSLog(@"Die!");
}
return 0;
}
I can see that the request starts (LittleSnitch shows a connection attempt to ansa.it - a test domain), but no completion block is ever called.
Additionally, if I try to set a breakpoint on the completion block inside the AFHTTPRequestOperation class ( https://github.com/AFNetworking/AFNetworking/blob/bb39a33ba242b50a2d779e37b4a836f4471160a5/AFNetworking/AFHTTPRequestOperation.m#L115 line 115), I see it never gets called.
There is plenty of time before the process dies, and anyways I'm making sure that doesn't happen before the request is complete, by telling the main thread to wait for the queue to be done and/or to pause the main thread.
I'm developing on OSX 10.10 Yosemite GM 2.0 (last version until 3 hours ago), XCode 6.1 GM on x86_64.
I'm getting errors with both the last stable release of AFNetworking (2.4.1 as of writing) and the code on the master branch.
Please help!