Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一些在主线程上运行的代码,以及一个正在处理一些数据的辅助 GCD 线程。处理完数据后,我需要更新 UI,最好尽快更新,那么我是否可以将其移至主线程以立即处理?谢谢!
void es_dispatch_sync_on_main_thread(dispatch_block_t block) { if ([NSThread isMainThread]) { block(); } else { dispatch_sync(dispatch_get_main_queue(), block); } }