Skip to content

Instantly share code, notes, and snippets.

@radianttap
Created February 19, 2018 20:30
Show Gist options
  • Save radianttap/c06445d8cd24ed636a4f12fe5370a0c5 to your computer and use it in GitHub Desktop.
Save radianttap/c06445d8cd24ed636a4f12fe5370a0c5 to your computer and use it in GitHub Desktop.
Why the hell this crashes in UICollectionView?
let expandedSections = [0, 3, 8]
let indexSet = IndexSet(expandedSections)
collectionView?.performBatchUpdates(
{
[unowned self] in
if isInserted {
self.collectionView?.insertItems(at: indexPaths)
} else {
self.collectionView?.deleteItems(at: indexPaths)
}
if !indexSet.isEmpty {
self.collectionView?.reloadSections(indexSet)
}
}, completion: {
_ in
}
@ivanglushko
Copy link

ivanglushko commented Jul 7, 2021

Hi I'm facing the same issue using framework for CollectionView well that is weird.
Thanks for posting the reason why it happens.
Although i did not understand fully why this is happening.
My only hint is that somehow indexSet is over-floating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment