Whenever AFNetworking is used the call is dispatched on a custom thread provided by AFNetworking. When the call returns to the completion block, it gets executed on the main thread.
This example sets a custom thread that dispatch to the completion block:
// Create dispatch_queue_t with your name and DISPATCH_QUEUE_SERIAL as for the flag dispatch_queue_t myQueue = dispatch_queue_create("com.CompanyName.AppName.methodTest", DISPATCH_QUEUE_SERIAL); // init AFHTTPRequestOperation of AFNetworking operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; // Set the FMDB property to run off the main thread [operation setCompletionQueue:myQueue];
AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] init]; [self setCompletionQueue:myQueue];