我在使用Swift,iOS 8,Xcode 6 Beta 6中的tableView中删除一行时遇到了一些麻烦.每当我尝试删除一行时,我都会遇到错误.
断言失败 - [UITableView _endCellAnimationsWithContext:],/ SourceCache/UIKit_Sim/UIKit-3302.3.1/UITableView.m:1581 2014-08-30 20:31:00.971类目录[13290:3241692]***终止应用程序未捕获的异常'NSInternalInconsistencyException',原因:'无效更新:第1节中的无效行数.更新后现有部分中包含的行数(25)必须等于更新前该部分中包含的行数(25),加上或减去从该部分插入或删除的行数(插入0,删除1),加上或减去移入或移出该部分的行数(0移入,0移出).
我已经阅读了这个常见问题的所有答案,并且觉得我已经满足了建议的条件.该项似乎从数据模型中删除 - 当我重新加载应用程序时,已删除的项目从表中消失 - 但在相应的sqlite文件中似乎有一些残余,当然数学不会加起来.吐出indexPath的println显示正确的Section和Row.我很困惑.这应该是直截了当但我遗漏了一些愚蠢的我确定,我怀疑在数据模型删除.Github上的完整项目.
func numberOfSectionsInTableView(tableView: UITableView!) -> Int {
return fetchedResultController.sections.count
}
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
return fetchedResultController.sections[section].numberOfObjects
}
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
let cell = tableViewMain.dequeueReusableCellWithIdentifier("CellMain", forIndexPath: indexPath) as UITableViewCell
let personForRow = fetchedResultController.objectAtIndexPath(indexPath) as Person
cell.textLabel.text = personForRow.fullName()
return cell
}
func tableView(tableView: UITableView!, canEditRowAtIndexPath indexPath: NSIndexPath!) -> Bool …Run Code Online (Sandbox Code Playgroud)