How we can iterate through all UItableview cells(visible & invisible) and get its property swift5

I'm able to get for visible but for invisible I'm getting null cell error or undefined cell

let rowCount  = tableView.numberOfRows(inSection: 0)
or row in 1 ..< rowCount {
                      
                        let cellObj = tableView.cellForRow(at: NSIndexPath(row: row, section: 0) as IndexPath) as! selectVehTableViewCell
selectedId.append(cellObj.vid.text!)
                        }

That's normal behaviour, as explained in documentation for cellForRow(at:):

Return Value

The cell object at the corresponding index path. In versions of iOS earlier than iOS 15, this method returns nil if the cell isn’t visible or if indexPath is out of range. In iOS 15 and later, this method returns a non-nil cell if the table view retains a prepared cell at the specified index path, even if the cell isn’t currently visible. 

Discussion

In iOS 15 and later, the table view retains a prepared cell in the following situations: Cells that the table view prefetches and retains in its cache of prepared cells, but that aren’t visible because the table view hasn’t displayed them yet. Cells that the table view finishes displaying and continues to retain in its cache of prepared cells because they remain near the visible region and might scroll back into view. The cell that contains the first responder. The cell that has focus.

How to solve this ?

You should have a data source for the tableView. Just use it to get vid.text for each.

If you need more details, please show your implementation of

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { }
How we can iterate through all UItableview cells(visible &amp; invisible) and get its property swift5
 
 
Q