sametbilgi
sametbilgi

Reputation: 602

Getting identifier of custom cells

i have 2 custom cell which singleCell and doubleCell. I want to know which one selected when didSelectItemAt method trigered.

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
    if singleSelected {
        print("SINGLE CELL SELECTED)
    } else {
        print("DOUBLE CELL SELECTED)
    }
}

Thanks.

Upvotes: 0

Views: 98

Answers (1)

Rashwan L
Rashwan L

Reputation: 38833

You can do it by checking the cellForItem in your didSelectItemAt function:

if let singleCell = collectionView.cellForItem(at: indexPath) as? SingleCell {
    // singleCell selected
} else {
    // doubleCell selected
}

Upvotes: 1

Related Questions