Skip to content

Instantly share code, notes, and snippets.

@yuchuanfeng
Created July 23, 2018 07:20
Show Gist options
  • Save yuchuanfeng/b16de44815bf570b87fd057e477b4bf6 to your computer and use it in GitHub Desktop.
Save yuchuanfeng/b16de44815bf570b87fd057e477b4bf6 to your computer and use it in GitHub Desktop.
import Foundation
class CallRollTool {
static private var outMark = 0
static private var inMark = 0
static func call(interval: TimeInterval = 0.5, _ callBack:@escaping (()->())){
outMark += 1
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + interval) {
inMark += 1
if outMark == inMark{
inMark = 0
outMark = 0
callBack()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment