How to get indexPath in cell class?

I'm trying to get the indexPath of a tableView cell in the cell class.

I've got a collectionView inside the table view cells and I'm trying to make label inside the collectionView cell show the indexPath.row of the tableView cell that particular collectionView in.


Currebtly i have

var indexPathForCell: indexPath

in my cell class.


Then in the tableView class i have this in cellForRowAt indexpath

cell.indexpathForCell = indexPath
lbl.text = String(indexPathForCell.row)


If there is "3" or fewer tableView cells this works but if theres more then the 4th row then shows "0" as the indexPathForcell.row, and as I scroll in the collectionView the numbers then chnage from "0" to "3" and even show "1". Each cell then shows a different number as i scroll.

How to get indexPath in cell class?
 
 
Q