Created
July 23, 2018 07:20
-
-
Save yuchuanfeng/b16de44815bf570b87fd057e477b4bf6 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
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