performSelectorOnMainThread中的WaitUntilDOne有什么意义?
YES 或 NO 设置为 WaitUntilDone 可以在 App 上有什么方式?
更新:
我的问题应该是:它们在什么情况下会产生影响?
Sergio 的回答符合我的预期。
最佳答案
来自 Apple docs about waitUntilDone :
A Boolean that specifies whether the current thread blocks until after the specified selector is performed on the receiver on the main thread. Specify YES to block this thread; otherwise, specify NO to have this method return immediately. If the current thread is also the main thread, and you specify YES for this parameter, the message is delivered and processed immediately.
您必须关注哪个线程正在执行 performSelectorOnMainThread。该线程将阻塞并等待主线程完成该选择器;例如,工作线程需要向主线程发送消息(例如,将一些信息存储到某个非线程安全的中央存储区)。 worker 可能想要阻塞并等待操作完成,然后再发出另一个同类操作。所以,waitUntilDone 在这种情况下就派上用场了。
关于objective-c - performSelectorOnMainThread中的WaitUntilDOne有什么意义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8943730/