Domanda di colloquio di Uber

Implement async task dispatcher with ability to cancel tasks, using GCD internally.

Risposte di colloquio

Anonimo

24 giu 2019

NSOperations use GCD “internally”, I wonder if setting that up would have been an acceptable answer, since it already has cancel? Probably not, they probably want the implementation.

Anonimo

30 ott 2017

We can create a class DispatchCancelTask with a cancel property and static method with return type as the class. Parameters to the method can be the queue, type, and completion handler as closure with void input and return type, check for is canceled property before executing the closure.