В основном я хочу удалить всплывающую кнопку JSON, извлеченную из базы данных. Данные удаляются из JSON, но они все еще отображаются в ячейке табличного представления. Что нужно сделать, это обновить таблицу. Любая помощь будет оценена Спасибо
![enter image description here](https://i.stack.imgur.com/UZE6k.png)
let cancelAction = UIAlertAction(title: "OK", style: .default) { (_) in
self.cancelbooking()
// mytableView.deleteRows(at: [indexPath], with: .middle)
self.mytableView.reloadData()
}
Вот функция для данных json для выборки из таблицы записей
func cancelbooking(){
let ph = defaults.string(forKey: "mobno")
print("cancelbooking booking value1 \(bookingidvalue2)")
print("cancelbooking booking date \(bookingdatevalue1)")
var request = URLRequest(url: URL(string: "http://ottokonnect.com/api/charging-station/booking-cancel")!)
request.httpMethod = "POST"
request.addValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.addValue("application/json", forHTTPHeaderField: "Accept")
do{
let postString = "booking_id="+bookingidvalue1+"&booking_date="+bookingdatevalue1+"&start_at="+startatvalue1+"&end_at="+endatvalue1+"&mobile="+ph!
print("postrsing is \(postString)")
request.httpBody = postString.data(using: .utf8)
self.activityIndicator("Please Wait")
}catch let error{
//print(error.localizedDescription)
return
}
let task = URLSession.shared.dataTask(with: request){
(data, response, error) in
if (error != nil){
return
}
do{
let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary
if let parseJSON = json{
//print(parseJSON)
if let userId = parseJSON["error"] as! Int? {
let msg = parseJSON["message"] as! String?
if (userId == 0){
//print(userId)
DispatchQueue.main.async {
// self.showGlobalAlertwithMessage(msg as! NSString)
DispatchQueue.main.async {
self.effectView.removeFromSuperview()
}
}
}else {
DispatchQueue.main.async {
// self.showGlobalAlertwithMessage(msg as! NSString)
DispatchQueue.main.async {
self.effectView.removeFromSuperview()
}
}
}
}
} else{
self.showGlobalAlertwithMessage("Could not successfully perform this request. Please try again later")
DispatchQueue.main.async {
self.effectView.removeFromSuperview()
}
}
}catch{
self.showGlobalAlertwithMessage("Could not successfully perform this request. Please try again later")
DispatchQueue.main.async {
self.effectView.removeFromSuperview()
}
//print(error)
}
}
task.resume()
}