Uber interview question

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

Interview Answers

Anonymous

24 June 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.

Anonymous

30 Oct 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.