Created
May 15, 2017 03:06
-
-
Save jackyshan/4d92b8de1f0fc793748b0952bc158cbf to your computer and use it in GitHub Desktop.
rxswift实现定时器
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
let interval = Observable<Int>.interval(0.6, scheduler: MainScheduler.instance) | |
let disinterval = interval.subscribe(onNext: { (time) in | |
guard time < lines.count else { | |
return | |
} | |
self.searchBusLine(lineId: lines[time].gid) | |
}) | |
let timeE:DispatchTime = DispatchTime.now() + Double(lines.count*Int(NSEC_PER_SEC)) / Double(NSEC_PER_SEC); | |
DispatchQueue.main.asyncAfter(deadline: timeE) { | |
disinterval.dispose() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment