近期发现xcode7 连接iphone6(ios8.4)和iphone6plus(ios8.4)时会报错
Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit/UIKit-3347.44/UITableView.m:1222
xcode6却不会出现此问题,经过追查,发现uitableview在movecell的时候delete和reload的是同一行。
NSFetchedResultsController during a call to -controllerDidChangeContent:. attempt to delete and reload the same index path ( {length = 2, path = 0 - 0}) with userInfo (null)
该问题目前判断为xcode7或者ios9的bug,解决方案为在move时先判断index path和newindexpath是否是同一个即可。
case .Move:
if let indexPath = indexPath {
if let newIndexPath = newIndexPath {
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
tableView.insertRowsAtIndexPaths([newIndexPath], withRowAnimation: .Fade)
}
}
stackoverflow上有很多体温和解决方案,最符合我的就是如下两个讨论
http://stackoverflow.com/questions/31383760/ios-9-attempt-to-delete-and-reload-the-same-index-path
http://stackoverflow.com/questions/31968574/core-data-setting-the-relationship-on-an-entity-causes-error-in-fetch-results-c