Таблица не обновляется после вызова API. И вот мой код. И я использую dequeueReusableCell (withIdentifier: "Cell", for: indexPath) как! Ячейка в cellforRowatIndexpath, что-то не так с этим?
func getPreviousHistory() {
DispatchQueue.main.async {
let url = ServiceUrl.userOrder
var previousOrderArray = [[:]]
let params1: [String : String] = [
"userid" : UserDefaults.standard.string(forKey: "userid")!
]
print(params1)
Alamofire.request(url, method: .post, parameters: params1).responseJSON() {
response in
switch response.result {
case .success:
if let data = response.result.value {
if (data as? [String : AnyObject]) != nil{
if let dictionaryArray = data as? Dictionary<String, AnyObject> {
previousOrderArray = dictionaryArray["data"] as! Array<Dictionary<String, AnyObject>>
self.sortedOrdersDictionary = self.sortArrayDictDescending(dict: previousOrderArray as! Array<Dictionary<String, AnyObject>>, dateFormat: "yyyy-MM-dd'T'HH:mm:ss")
DispatchQueue.main.async( execute: {
self.tableView.reloadData()
})
}
}
}
case .failure(let error):
print("RESPONSE ERROR: \(error)")
if let err = error as? URLError, err.code == URLError.Code.notConnectedToInternet
{
DispatchQueue.main.async {
popupConstants.sharedInstance.showAlert(title: "ALERT", message: "Please check your Internet connection",view: self)
}
}
else
{
DispatchQueue.main.async {
popupConstants.sharedInstance.showAlert(title: "ALERT", message: "An Error Occured",view: self)
}
}
}
}
}
}`