I use an animation for specify a tip to help the interaction with delay using these:
let delay = 1.8 * Double(NSEC_PER_SEC)
let time = dispatch_time(DIS
iOS 8 and OS X Yosemite introduced dispatch_block_cancel that allow you to cancel them before they start executing
You declare one variable in class as follows:
var block: dispatch_block_t?
Init block variable and provide it in dispatch_after:
block = dispatch_block_create(DISPATCH_BLOCK_INHERIT_QOS_CLASS) {
print("I executed")
}
let time: dispatch_time_t = dispatch_time(DISPATCH_TIME_NOW, Int64(5 * NSEC_PER_SEC))
dispatch_after(time, dispatch_get_main_queue(), block!)
After that you can cancel it as follows:
dispatch_block_cancel(block!)