Search code examples
iosswiftuicollectionviewcosmicmind

Unable to Set Initializer for Custom UICollectionView Cell Class


I am trying to set an initializer for a custom UICollectionViewCell class and I am receiving an error. I am new to Swift and understand that a model class must have a relevant initializer in order to use items from the class. Here is my code and the error I am receiving:

enter image description here


Solution

  • You need to set a default value to your key variable or make it Optional

    var key: String?