There is no reason why your code should dead-lock. But there might be a misunderstanding
about the queue
parameter. That is the queue on which the completion block is
executed, not the queue that is used for loading the data in the background.
sendAsynchronousRequest
does always load the data on a background queue and does not block the main thread.
Therefore, to execute the completion handler on the main thread, you don't need
to create a operation queue, and you can simplify your code to:
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
{
// This is executed on the main thread.
// Update UI elements ...
if (error) {
}
}];