開啟
let timer = Timer.init(timeInterval: 15, target: self, selector: #selector(autoGet), userInfo: nil, repeats: true)
RunLoop.main.add(timer, forMode: RunLoop.Mode.common)
self.timer = timer
定時任務(wù)內(nèi)容
// 每15秒自動獲取一次數(shù)據(jù)
@objc func autoGet() {
self.getAllExchangeSymbol()
self.getAllNetWorkSymbol()
}
結(jié)束任務(wù)
self.timer?.invalidate()
self.timer = nil