gpt4 book ai didi

ios - 应用程序崩溃然后重新加载 tableview 数据

转载 作者:行者123 更新时间:2023-11-28 14:12:45 26 4
gpt4 key购买 nike

<分区>

我在重新加载我的 tableview 时遇到问题。然后我在我的 tableview 上删除了一些东西,tableview 应该重新加载并且数据应该上升。但是然后我删除了一些没有任何反应并且行之间有一些空格。我尝试使用 tableview.deleterows 但在我实现此方法后我的应用程序崩溃了..

Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (4) must be equal to the number of rows contained in that section before the update (4), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).

if editingStyle == UITableViewCellEditingStyle.delete {
//let mt = movieArray2[indexPath.row]

//1
guard let appDelegate =
UIApplication.shared.delegate as? AppDelegate else {
return
}

let managedContext =
appDelegate.persistentContainer.viewContext
managedContext.delete(self.movieArray2[indexPath.row])
tableView.deleteRows(at: [indexPath], with: .automatic)


do{
try managedContext.save()
} catch {

}

}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com