Skip to content

Instantly share code, notes, and snippets.

View alimir1's full-sized avatar

Ali Mir alimir1

View GitHub Profile
@baarde
baarde / SynchronousAFNetworking.m
Last active October 7, 2017 20:05
How to use AFNetworking synchronously
#import "AFNetworking.h"
int main(void)
{
NSURL *baseURL = [NSURL URLWithString:@"http://graph.facebook.com/"];
AFHTTPRequestOperationManager *operationManager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:baseURL];
AFHTTPRequestOperation *operation = [operationManager GET:@"Octiplex" parameters:nil success:nil failure:nil];
[operationManager.operationQueue waitUntilAllOperationsAreFinished];
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate date]]; // Executes async notification blocks waiting in the main queue
NSLog(@"Response: %@", operation.responseObject);