gpt4 book ai didi

objective-c - performSelectorOnMainThread 调用何时执行?

转载 作者:搜寻专家 更新时间:2023-10-30 20:23:26 24 4
gpt4 key购买 nike

如果我在分离线程中使用 performSelectorOnMainThread 调用,主线程何时执行请求?它是在完成当前主线程操作后立即执行此操作,还是存在其他类型的层次结构来确定何时执行 performSelectorOnMainThread 调用?

最佳答案

它在主线程运行循环的下一次迭代时在主线程上执行。

引用 Apple 的文档:

This method queues the message on the run loop of the main thread using the default run loop modes—that is, the modes associated with the NSRunLoopCommonModes constant. As part of its normal run loop processing, the main thread dequeues the message (assuming it is running in one of the default run loop modes) and invokes the desired method.

关于objective-c - performSelectorOnMainThread 调用何时执行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3274798/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com