katleta3000/CancelBlocks

语言: Swift

git: https://github.com/katleta3000/CancelBlocks

用于在延迟之后调度块的功能集,具有取消它们的能力。用Swift写的。
Set of functions for dispatching blocks after a delay, with the ability to cancel them. Written in Swift.
README.md (中文)

CancelBlocks

用于在延迟之后调度块的功能集,具有取消它们的能力。用Swift写的。

使用dispatch_block_t而不是native dispatch_after并使用dispatch_cancelable_block_t类型保存执行块,之后您可以使用dispatch_cancel_block_t安全地使用它来取消执行块。

dispatch_cancelable_block_t将您的块包装在一个类型(Bool) - > Void中,它处理取消。

用法示例:

var block: dispatch_cancelable_block_t? = dispatch_block_t(1, {
    // Your code 
})
dispatch_cancel_block_t(block)

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

CancelBlocks

Set of functions for dispatching blocks after a delay, with the ability to cancel them. Written in Swift.

Use dispatch_block_t instead of native dispatch_after and save the executing block with type dispatch_cancelable_block_t, afterwards you may safely use it to cancel executing the block by using dispatch_cancel_block_t.

dispatch_cancelable_block_t wraps your block in a block of type (Bool) -> Void which handles cancellation.

Usage example:

var block: dispatch_cancelable_block_t? = dispatch_block_t(1, {
    // Your code 
})
dispatch_cancel_block_t(block)