0

I am running the following code and getting error in swift.

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
     let cell = Collection_View.dequeueReusableCell(withReuseIdentifier: "list", for: indexPath) as! List_CollectionViewCell
     cell.list_name.text = items[indexPath.row]
     **cell.created_date.text = c_date[indexPath.row]**
     return cell
}

why is xcode generating this error on this line?

Adam Strauss
  • 1,889
  • 2
  • 15
  • 45

1 Answers1

1

This error arises when there is a failed force unwrapping. Make sure that the class of the prototype in your storyboard is set to List_CollectionViewCell in the Identity Inspector:

class

and that its identifier is "list" in the Attributes inspector:

identifier

ielyamani
  • 17,807
  • 10
  • 55
  • 90