Created
June 15, 2016 09:27
-
-
Save quangtqag/668e056828034eddb469d9a7828117e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var block: dispatch_block_t? | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
} | |
override func viewDidAppear(animated: Bool) { | |
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!) | |
} | |
@IBAction func didTapButton(sender: UIButton) { | |
dispatch_block_cancel(block!) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment