当我删除一行时,swift中出现错误,它会这样做,但会崩溃

当我删除一行时,swift中出现错误,它会这样做,但会崩溃,swift,crash,Swift,Crash,当我决定使用delete时,它成功了,但应用程序崩溃了 这是-[UITableView\u endCellAnimationsWithContext:]、/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit\u Sim/UIKit-3512.30.14/UITableView.m:1720中的错误 2016-01-19 00:07:30.451注册表1[21154:852511]* 从UITableView中删除任何行后,需要调用reload

当我决定使用delete时,它成功了,但应用程序崩溃了

这是-[UITableView\u endCellAnimationsWithContext:]、/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit\u Sim/UIKit-3512.30.14/UITableView.m:1720中的错误 2016-01-19 00:07:30.451注册表1[21154:852511]*


UITableView
中删除任何行后,需要调用
reloadData()
,或者可以将该方法绑定到
beginUpdates
endUpdates()

例如:


希望这有帮助

从代码中,似乎没有从数据源数组中删除相应的对象,
noteObjects
。因此,在调用
deleteRowsAtIndexPaths

tableView.beginUpdates()
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
tableView.endUpdates()
在调用
tableView.deleteRowsAtIndexPaths

tableView.beginUpdates()
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
tableView.endUpdates()

现在我在-[UITableView\u endCellAnimationsWithContext:]、/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit\u Sim/UIKit-3512.30.14/UITableView.m:1720 2016-01-19 10:21:33.980 Registro1[21521:899913]***中遇到了这个错误***断言失败,它是一个分区的表格视图吗?如果要删除的行是节中的最后一项,则需要删除整个节。否则,它会引发此异常。我试图使用您的代码,但它会引发错误,并尝试了Sohil R.Memon解决方案。它删除了孔对象,但应用程序崩溃包含代码片段,以显示如何填充表视图。这将有助于更多地了解您的问题。
tableView.beginUpdates()
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
tableView.endUpdates()
self.noteObjects.removeAtIndex(indexPath.row)