UITableView内部错误:无法生成具有旧节数的新节映射:和新节数:with userInfo(null) [英] UITableView internal bug: unable to generate a new section map with old section count: and new section count: with userInfo (null)

查看:153
本文介绍了UITableView内部错误:无法生成具有旧节数的新节映射:和新节数:with userInfo(null)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之前我没有看到过这个错误,我搜索了为什么会发生这种错误但却找不到任何相关信息:

I haven't seen this error before, and I did a search as to why it may be happening but couldn't find any info on it:


CoreData:错误:严重的应用程序错误。在调用
-controllerDidChangeContent:期间,来自NSFetchedResultsController委托的
异常被捕获。 UITableView内部错误:无法生成具有旧部分计数的新部分地图:1和新部分
count:0 with userInfo(null)

CoreData: error: Serious application error. An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:. UITableView internal bug: unable to generate a new section map with old section count: 1 and new section count: 0 with userInfo (null)

有谁知道这里可能会发生什么?我不确定内部错误部分 - 此错误是否表示我的代码存在问题或UITableView中存在错误?

Does anyone know what might be happening here? I am not sure about the "internal bug" part - does this error indicate a problem with my code or a bug in UITableView?

推荐答案

< Stephan在对原始问题的评论中已经提到了这一点,但我认为值得分享一些代码。这个答案实际上来自用户 GERUB 在Apple dev论坛上的一个帖子上发表的评论: https://forums.developer.apple.com/thread/9964

Stephan already mentioned this in a comment on the original question but I thought it was worth sharing some code. This answer was actually sourced from a comment made by user GERUB on a thread on the apple dev forums found here: https://forums.developer.apple.com/thread/9964

if tableView.numberOfRowsInSection(indexPath.section) == 1{  
    tableView.deleteSections(NSIndexSet(index: indexPath.section), withRowAnimation: .Automatic)  
}else{  
    tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)  
} 

我已经在 NSFetchedResultsControllerDelegate 方法实现中对此进行了测试,它运行良好。

I have tested this inside of the NSFetchedResultsControllerDelegate method implementations and it works perfectly.

这篇关于UITableView内部错误:无法生成具有旧节数的新节映射:和新节数:with userInfo(null)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆