Difference between DispatchQueue.main.async and DispatchQueue.main.sync

后端 未结 4 2268
孤街浪徒
孤街浪徒 2020-11-28 01:46

I have been using DispatchQueue.main.async for a long time to perform UI related operations.



Swift provides both DispatchQueue.main.async

4条回答
  •  独厮守ぢ
    2020-11-28 01:55

    GCD allows you to execute a task synchronously or asynchronously[About]

    synchronous(block and wait) function returns a control when the task will be completed

    asynchronous(dispatch and proceed) function returns a control immediately, dispatching the task to start to an appropriate queue but not waiting for it to complete.

    [DispatchQueue]

提交回复
热议问题