I am hoping to learn whether there are any negative implications of running an asynchronous NSURLConnection inside of a dispatch. I am using a dispatch because it seems much cleaner than a timer for my purposes.
The call is asynchronous, but I want to ensure that using dispatch_after will not block the UI. Can someone help me understand if dispatch_after will block the UI/app in any way for those 10 seconds? Thank you!
int delaySeconds = 10;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delaySeconds
* NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
aURL = [NSURL URLWithString:@"http://google.com"];
request = [NSMutableURLRequest requestWithURL:aURL
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
[NSURLConnection sendAsynchronousRequest:request queue:
[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response) {
//do something with response
}];
});
P.S. I have taken a look at Does dispatch_after block the main thread? but I'm still a bit confused.