我試圖從api設置標籤上的文本,但似乎該函數甚至沒有被調用。請參閱下面的代碼片段。它有什麼問題嗎?Alamofire從JSON API下載
編輯:typealias DownloadComplete等=() - >()
var date: String = ""
override func viewDidLoad() {
super.viewDidLoad()
timeLbl.text = date
// Do any additional setup after loading the view.
}
func downloadTimeData(completed: @escaping DownloadComplete) {
//Downloading forecast weather data for TableView
Alamofire.request(APIURL).responseJSON { response in
let result = response.result
if let dict = result.value as? Dictionary<String, AnyObject> {
if let currentDate = dict["fulldate"] as? String {
self.date = currentDate
print(self.date)
print("xxx")
}
}
completed()
}
}
我編輯它並定義了DownloadComplete –
@HonzaValta我更新了我的答案。 – naglerrr