【发布时间】:2016-09-19 19:38:56
【问题描述】:
我不知道如何让调度计时器在 Swift 3.0 中重复工作。我的代码:
let queue = DispatchQueue(label: "com.firm.app.timer",
attributes: DispatchQueue.Attributes.concurrent)
let timer = DispatchSource.makeTimerSource(flags: DispatchSource.TimerFlags(rawValue: UInt(0)),
queue: queue)
timer.scheduleRepeating(deadline: DispatchTime.now(),
interval: .seconds(5),
leeway: .seconds(1)
)
timer.setEventHandler(handler: {
//a bunch of code here
})
timer.resume()
定时器只会触发一次,不会像应有的那样重复。我该如何解决这个问题?
【问题讨论】:
标签: swift grand-central-dispatch swift3 dispatch