1

Text

I cannot figure out how to change the label text on my collection view cell when the user presses the cell, from "not added" to "added" the model is a struct.

Please reference my repo for more information.

override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {

    shoppingListController.shoppingItems[indexPath.item].itemHasBeenAdded.toggle()
}

This is what I have so far but is giving me an error saying that it is an immutable value.

Nikunj Kumbhani
  • 3,758
  • 2
  • 26
  • 51

1 Answers1

0

You need to change the ShoppingItem construct from struct to class type to mutate the value of variable of ShoppingItem. To have greater insights check this answer