Search code examples
swiftuikit

high frequency (0.01 sec) realoadAt call for UICollectionview bumps cpu usage to 100%


I am looking to call collectionView.reloadItems(at: [IndexPath(item: middle, section: 0)]) at frequency of 0.01 second to just update single cell, but it bumps cpu usage to 100%.

Any suggestion is welcome to bring it down.


Solution

  • You should not do that, just need to get the cell at indexPath you want:

    if let cell = collectionView.cellForItem(at: IndexPath(item: 10, section: 0)) as? `YourCollectionViewCellClass` {
        //Update cell data here instead of reloading
    }