Cancelling dispatch_after?

Graham Cox

Hi all,

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

While I’m finding the functionality it offers really useful, it seems like as soon as you use it you have to commit to that code being run, even if circumstances change before it does so. As a result I’m having to use flags and other awkward means to prevent the ‘meat’ of the block running. If not I may have to go back to the -performSelector:afterDelay:.. approach which can be cancelled.


Join { to automatically receive all group messages.