I am trying to create a function, with which I can switch the background color of a UICollectionViewCell
, depending on which cell is selected and on what color gets selected. I created these two functions:
func selectedCell (at indexPath: IndexPath) {
let indexPathForFirstRow = indexPath
gamePad.selectItem(at: indexPathForFirstRow, animated: false, scrollPosition: UICollectionView.ScrollPosition(rawValue: 0))
}
@IBAction func selectedColor(_ sender: UIButton) {
let cell = self.selectedCell(at: IndexPath)
cell.backgroundcolor = sender.currentTitleColor
}
In the second function, there occurs the problem, that I can't use IndexPath or indexPath.
How can I solve this problem?
That's the error which is shown when I use IndexPath
Cannot convert value of type 'IndexPath.Type' to expected argument type 'IndexPath'
That's the error which is shown when I use indexPath
Use of unresolved identifier 'indexPath'; did you mean 'IndexPath'?