core-data icon indicating copy to clipboard operation
core-data copied to clipboard

Update fails if the cell is not visible

Open Sydney-o9 opened this issue 6 years ago • 0 comments

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])

Sydney-o9 avatar Apr 14 '18 09:04 Sydney-o9