Junior — Middle
Where is monitoring and tracking of completed tasks carried out?
sobes.tech AI
Answer from AI
In iOS, monitoring and tracking completed tasks are usually done using classes from Grand Central Dispatch (GCD) and OperationQueue.
- DispatchGroup allows grouping multiple asynchronous tasks and tracking their completion.
- OperationQueue and Operation provide a higher level of abstraction, where you can monitor the state of operations through properties like
isFinished,isExecuting, and use delegates or KVO.
For example, with DispatchGroup, you can execute code after all tasks are completed:
group.enter()
DispatchQueue.global().async {
// task
group.leave()
}
group.notify(queue: .main) {
// code after all tasks are finished
}