If I use NSURLConnection
with sendAsynchronousRequest:queue:completionHandler:
, do I need to take any particular precautions inside the completion handler? Specifically, is sending asynchronously directly via NSURLConnection
the same/similar as using dispatch_async
in that the completion block would need to come back to the main thread to interact with the UI?
For example: after using dispatch_async
to interact (maybe the wrong word) with the UI, the app must use performSelectorOnMainThread
.
Is that a consideration at all with sendAsynchronousRequest:queue:completionHandler:
?
note: I have found similar questions, but not this specifically. eg, in Does NSURLConnection block the main thread? indiekiduk specifically states it is a new thread, albeit an internal one--I think that is flawed, since I thought it was just at the end of the run loop--but I am still learning and probably/possibly wrong.
The documentation for NSURLConnection
states for the queue parameter to sendAsynchronousRequest:queue:completionHandler:
queue
The operation queue to which the handler block is dispatched when the request completes or > failed.
The block will execute on whichever thread the passed in queue was set up on.
NSURLConnection sendAsync是在AFAIK上的线程的RunLoop上调度的,所以在启动它的线程中调用该块
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.