I want to wrap an async API that look like this:
[someObject completeTaskWithCompletionHandler:^(NSString *result) { }];
into a synchronous m
Using an NSRunLoop is the easiest to do here.
__block NSString* result = nil; [self completeTaskWithCompletionHandler:^(NSString *resultstring) { result = resultstring; }]; while (!result) { [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; }