Re: Cancelling dispatch_after?


 



On Nov 8, 2017, at 4:15 PM, Graham Cox <graham@...> wrote:

In addition, the documentation for dispatch_after says that the function copies and releases the block on behalf of the caller. Wouldn’t that mean that my reference isn’t the same block, so the cancel wouldn’t work anyway?

I think ARC copies the block automatically if you assign it to a variable instead of just having it as a parameter of a function/method call. (A block really only gets copied once; it’s more like “detached”, so that it can be used after the stack frame that created it has returned. After that, any further copies are no-ops.)

—Jens

Join {cocoa@apple-dev.groups.io to automatically receive all group messages.