I'm new to Swift.. I'm trying to do a try catch to make sure I'll not have any problems when I try to remove a row from my tableview and from my notes array.
Here's the code
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
do{
try removerowtableview(indexPath: indexPath)
}catch{
print(error.localizedDescription)
}
}
func removerowtableview(indexPath: IndexPath) throws{
dataModel.notas.remove(at: 1000) //1000 to force to crash
self.tableView.deleteRows(at: [indexPath as IndexPath], with: UITableViewRowAnimation.fade)
dataModel.saveData()
}
dataModel.notas
is my array of notes and I want it to not crash the app and print the error, but I get terminating with uncaught exception of type NSException
. Why? What am I doing wrong?
Thanks in advance and sorry for some English mistakes.