Я пытаюсь удалить элемент из массива внутри словаря, но значение не удаляется из словаря, когда я удаляю его из таблицы. Является ли способ, которым я пытаюсь удалить массив неправильно?
marker.buttonAction["button actions array"]?.remove(at: indexPath.row)
//Function to remove array from dictionary and tableview.
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
if let marker = markUpPlist.arrayObjects.filter({$0.tagClip == currentSelectedMarker}).first {
print(marker.buttonAction["button actions array"]?[indexPath.row].action)
marker.buttonAction["button actions array"]?.remove(at: indexPath.row)
tableView.beginUpdates()
tableView.deleteRows(at: [indexPath], with: .automatic)
tableView.endUpdates()
}
}
}
//Variable which stores the dictionary
var buttonAction : [String: [ButtonAction]] = [:]
//ButtonAction array
class ButtonAction: Codable {
var action: String
var array_linked_of_buttons: [[String:String]]
init(action: String, array_linked_of_buttons: [[String:String]]) {
self.action = action
self.array_linked_of_buttons = array_linked_of_buttons
}
}