Re: Cancelling dispatch_after?

Quincey Morris

On Nov 8, 2017, at 14:03 , Graham Cox <graham@...> wrote:

Is there a way to cancel a scheduled block used with dispatch_after(…)?

If you mean “cancel” in the sense of “prevent it from starting”, then the answer is yes, you can use “dispatch_block_cancel”:

The original GCD didn’t have this ability, but it was added a few years ago.

You can’t cancel it once it’s started running, except by means of setting a flag as you mentioned earlier.

Join to automatically receive all group messages.