Variable assigned in dispatch block coming back null
I'm trying to make a network call run in a background thread so it doesn't freeze my app while it's waiting. The call happens when I do: nextTime = [myObj getNextTime]; I do an NSLog as soon as I get it, and that one works. However, when I'm outside of the dispatch block, the same NSLog prints out null. myObj *current = ((myObj *)sortedArray[i]); __block NSString *nextTime; dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul); dispatch_async(queue, ^{ nextTime = [myObj getNextTime]; NSLog(@"inside%@",nextTime); dispatch_sync(dispatch_get_main_queue(), ^{ });