JVS JVS - 8 months ago 109
Swift Question

UITableView.visibleCells() is not returning all cells

I am using a

. The
is presenting 11 custom Cells.
10 of those are dynamic, one is static.

Nevertheless counting the rows either with:

let cells = self.tableView.visibleCells as? [chatUebersicht]


for (var row = 0; row < gruppenNamen.count; row++) {
if let cell:chatUebersichtCell = table.cellForRowAtIndexPath(NSIndexPath(forRow: row, inSection: 0)) as? chatUebersichtCell {

is returning the correct number. It is returning the number 5 each time.
I think there is an issue with preloading the cells. is there a way to overcome this?


visibleCells only returns the reusable cells you can currently see. That's the beauty of a UITableView - There isn't an instance of a cell for every row of data.

You should reevaluate what you are trying to do and determine whether it's a presentational operation or something that can be done by working with your array of data that feeds the tableview's data source.