I am trying to create a CocoaPod for Swift 3. Because CocoaPods uses Nimble and Quick, and those libraries haven't been updated yet, I forked the repos and am trying to convert them.
In the Nimble project there is a function called with the signature of:
setTimer(start: DispatchTime, interval: UInt64, leeway: UInt64)
The compiler says Cannot invoke 'setTimer' with an argument list of type '(start: DispatchTime, interval: UInt64, leeway: UInt64)'
private let pollLeeway: UInt64 = NSEC_PER_MSEC
let interval = UInt64(pollInterval * Double(NSEC_PER_SEC))
asyncSource.setTimer(start: DispatchTime.now(), interval: interval, leeway: pollLeeway)
The auto-complete shows all the setTimer methods are deprecated, but from what I found they shouldn't be.
Is there a replacement?
In Swift 3.0 you should use
let timer = DispatchSource.makeTimerSource(flags: DispatchSource.TimerFlags(rawValue: UInt(0)), queue: DispatchQueue.global(qos: DispatchQoS.QoSClass.default))
timer.scheduleRepeating(deadline: DispatchTime.init(uptimeNanoseconds: UInt64(100000)), interval: DispatchTimeInterval.seconds(1), leeway: DispatchTimeInterval.seconds(0))
to instead, and it's work for me
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With