![](/img/trans.png)
[英]Is NSURLConnection sendAsynchronousRequest completion block executed on the main thread?
[英]NSURLConnection and sendAsynchronousRequest:queue:completionHandler: - does the completion block run in the main thread
如果我将NSURLConnection
与sendAsynchronousRequest:queue:completionHandler:
,我是否需要在完成处理程序中采取任何特殊的预防措施? 具体来说,是通过NSURLConnection
直接异步发送与使用dispatch_async
相同/相似,因为完成块需要返回主线程与UI交互?
例如:在使用dispatch_async
与UI交互(可能是错误的单词)后,应用程序必须使用performSelectorOnMainThread
。
这是sendAsynchronousRequest:queue:completionHandler:
一个考虑sendAsynchronousRequest:queue:completionHandler:
?
注意:我发现了类似的问题,但没有具体说明。 例如,在NSURLConnection中阻止主线程吗? indiekiduk特别指出它是一个新的线程,虽然是一个内部的 - 我认为这是有缺陷的,因为我认为它只是在运行循环结束 - 但我仍然在学习,可能/可能是错误的。
NSURLConnection
的文档说明sendAsynchronousRequest:queue:completionHandler:
的queue参数sendAsynchronousRequest:queue:completionHandler:
队列
请求完成或>失败时调度处理程序块的操作队列。
该块将在传入的队列中设置的任何线程上执行。
NSURLConnection sendAsync是在AFAIK上的线程的RunLoop上调度的,所以在启动它的线程中调用该块
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.