我的应用在首次执行时发出HTTP请求。如果我的应用程序在后台运行,该如何每小时更新一次数据?它是在AppDelegate和ViewController中完成的。
let task = URLSession.shared.dataTask(with: url) { (data, response, error) in
if let httpResponse = response as? HTTPURLResponse,
httpResponse.statusCode == 200,
let data = data,
let content = String(data: data, encoding: .utf8) {
self.csv = CSwiftV(with: content)
} else {print("ERROR")
}
}
task.resume()
}