前要
最近在弄那个使用UICollectionView的方法的刷新部分数据源的时候出现了crash,
[_dateCollection reloadItemsAtIndexPaths:tempRefreshIndexPath];
崩溃的信息是 attempt to delete item 72 from section 0 which only contains 0 items before the update,一直不知道什么原因,为什么会执行了delete的方法呢,删除cell的操作呢
原因
看了一份别人写的文章,才知道原因意思就是内部会先删除原来的cell再重新生成cell,所以才会出现delete操作,然而我这个错误的是,原来就没有cell。
[self refreshAllSelectIndex:_selectIndex withOldSeletIndex:oldIndex];会调用[_dateCollection reloadItemsAtIndexPaths:tempRefreshIndexPath];这个方法进行局部刷新