JK140
JK140

Reputation: 785

Swift iOS - optimal amount of cells in collectionView

I have collectionView in my swift app, each cell is composed of a thumbnail image.

Right now I have 100 cells initially, and I paginate results from my backend, so the user can click a next button to get the next 100 images, and I call collectionView.reloadData() so I re-use the initial 100 cells.

Is there an optimal amount of cells I should have? I can instead paginate by each 1000, so I have a 1000 cells, but I'm guessing this could cause problems having so many cells in memory at once?

Upvotes: 1

Views: 339

Answers (1)

Fattie
Fattie

Reputation: 12641

There's no limit at all.

"1000" is absolutely nothing.

Your only consideration here would be, what is a good chunk size to grab depending on your bandwidth.

That is to say, you have no issues whatsoever with the collection view. You just want to pick a good chunk size, so that in terms of networking, from the user's point of view it feels like it is loading smoothly. (Try 2500 to begin with and vary it up and down.) (In really sophisticated apps, you vary that amount dynamically, depending on measurements you make while the app is running, but that is irrelevant here.)

Again you have absolutely no issues, whatsoever, with the collection view. Set it to any value you want. Set it to 100 million if you feel like it.

Upvotes: 3

Related Questions