I\'m getting JSON data from the web, parse it, then using it to diplay pins on a map.
Here is method one, which there is no problem with:
NSString *CLIE
You need to ensure that UIKit methods will be executed on the main thread.
The block of the completion handler will be executed on the "delegate queue" (see delegateQueue property of NSURLSession
).
You can accomplish this in two ways: either setup the delegate queue which is the main queue ([NSOperationQueue mainQueue]
) or use
dispatch_async(dispatch_get_main_queue(), ^{
[self loadAnnotationsAndCenter:YES];
});
in your completion block.
In Swift:
dispatch_async(dispatch_get_main_queue()) {
}