Last active
September 25, 2016 15:57
-
-
Save peatiscoding/557fdb8e1d2cbcdcc10df2f3ddad3866 to your computer and use it in GitHub Desktop.
JavaScript setTimeout in Swift 2.0
This file contains hidden or 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
| // Basic.swift | |
| func setTimeout(delay:NSTimeInterval, block:()->Void) -> NSTimer { | |
| return NSTimer.scheduledTimerWithTimeInterval(delay, target: NSBlockOperation(block: block), selector: #selector(NSOperation.main), userInfo: nil, repeats: false) | |
| } | |
| func setInterval(interval:NSTimeInterval, block:()->Void) -> NSTimer { | |
| return NSTimer.scheduledTimerWithTimeInterval(interval, target: NSBlockOperation(block: block), selector: #selector(NSOperation.main), userInfo: nil, repeats: true) | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple usage: