I’m upgrading my iPhone application, which has the content downloading function using Http communication.
The event used to occur in the main thread and the NSURLConnectionDelegate functions used to be called in the other thread on iOS 4.
But when I tested the same code on iOS 5, I found that the NSURLConnectionDelegate functions were called in the main thread.
I did not use the NSURLConnection sendSynchronousRequest:, but the initWithRequest:.
Did Apple upgrade this part of NSURLConnection in iOS 5?
NSURLConnectionhas a few new methods in iOS 5 e.g.sendAsynchronousRequest: ..., so yes they updated it in some way.To fix it you could use
in your delegate method or simply dispatch on the right queue.
The docs state:
On what thread did you
-startyour connection?Try to wrap your
[connection startImmediately:YES]in adispatch_async(myThreadQueue ...)call.