<分区>
我正在使用 UITableViewController 并且需要在函数中重新加载表。当我运行该应用程序时,表格 View 没有重新加载。我没有收到任何错误。
代码:
func loadTheaters() {
let api = ""
let theaterId = id
let date = date
let url = URL(string: "http://data.tmsapi.com/v1.1/theatres/\(theaterId)/showings?startDate=\(date)&api_key=\(api)")
print(url!)
let request = URLRequest(
url: url! as URL,
cachePolicy: URLRequest.CachePolicy.reloadIgnoringLocalCacheData,
timeoutInterval: 10 )
let session = URLSession (
configuration: URLSessionConfiguration.default,
delegate: nil,
delegateQueue: OperationQueue.main
)
let task = session.dataTask(with: request, completionHandler: { (dataOrNil, response, error) in
if let data = dataOrNil {
do { let filmList = try! JSONDecoder().decode([Films].self, from: data)
self.films = filmList
self.tableView.reloadData()
}
}
})
task.resume()
}
为什么 tableview 没有重新加载?