我正在学习如何使用Realm,当我尝试更新列表时,出现索引超出范围错误,我是从TableView获取索引的
func updateToDo(toDoEntity: [ToDoEntity] , toDo: String, index: Int ,completion: @escaping (_ success: Bool) -> Void){
do {
self.database.beginWrite()
toDoEntity[index].toDo = toDo
self.database.add(toDoEntity, update: false)
try self.database.commitWrite()
completion(true)
}
catch {
print("Error While Add New ToDo")
completion(false)
}
}