core-data
core-data copied to clipboard
Update fails if the cell is not visible
If the UICollectionViewCell being updated is not visible, the update will trigger wrong cell type
:
case .update(let indexPath, let object):
guard let cell = self.collectionView.cellForItem(at: indexPath) as? Cell else { fatalError("wrong cell type") }
self.delegate.configure(cell, for: object)
https://github.com/objcio/core-data/blob/master/Moody/Moody/CollectionViewDataSource.swift#L69-L70
I'm sure there must be a reason, but why not use this instead:
case .update(let indexPath, let object):
self.collectionView.reloadItems(at: [indexPath])