How to dispatch code blocks to the same thread in iOS?

前端 未结 8 1678
广开言路
广开言路 2021-01-31 11:04

Main aspect of the question: It\'s about iOS. Can I somehow dispatch code blocks in a way, that they will all (a) run in background and (b) on the same thread?

相关标签:
8条回答
  • 2021-01-31 11:32

    Just like this,

    dispatch_asyn(dispatch_get_current_queue, ^ {
    });
    
    0 讨论(0)
  • 2021-01-31 11:41

    You can use NSOperationQueue. You can make it use just one thread by using method - (void)setMaxConcurrentOperationCount:(NSInteger)count. Set it to 1

    0 讨论(0)
提交回复
热议问题