UICollectionView Reload

Hello Devs, I'm currently trying to implement a UICollectionView.

I've created a custom cellview that contains 3 labels and nothing else, pretty basic

The issue I'm having is I'm basically refreshing my data at 5Hz, but by refreshing the CollectionView with reload method at 5 times a second , it makes the collectionview very laggy when scrolling and consumes large amounts of memory. Is there a proper way of doing this? I only have 10 cells in my collection view,

The reason I'm refreshing this data fast is because it gathers data over bluetooth and displaying live data on screen.
Do you change all the cells at 5 Hz, or just one ? If so, don't reload the full collection, just the content that need to be refreshed, with:
Code Block
func reloadItems(at: [IndexPath])


You can also do direct update:
  • for any cell that has to change, get the cell with callAtRow with

Code Block
func cellForItem(at: IndexPath) -> UICollectionViewCell?
  • update the cell content directly

Yeah, I pretty much will have to update all the cells. Would updating content directly with:
Code Block
func cellForItem(at: IndexPath) -> UICollectionViewCell?


Make it more performant? The cell size and everything stays the same, the only thing that changes are the label strings themselves and its actually only 1/3 labels per cell thats changing.

Make it more performant? 

If you mean 'well enuf', it depends on your goal(s), basically how often you want to sync changes with what's displayed to the user.

If you're cacheing multiple inputs until a 'done' button is pushed, sure.
If you use NSDiffableDatasource you can apply snapshots as often as you want. This is recommended over calling reloadData() with UICollectionViewDataSource.
UICollectionView Reload
 
 
Q