Hi,
i was following a tutorial and with the same code i have an unknown error.
The idea is to have a table view and inside a cell a collection view with a carrousel of images.
This is the code:
...
private let collectionView: UICollectionView = {
let layout = UICollectionViewFlowLayout()
layout.scrollDirection = .horizontal
layout.minimumLineSpacing = 0
layout.minimumInteritemSpacing = 0
layout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.register(UICollectionViewCell.self,
forCellWithReuseIdentifier: photoCollectionViewCell.identifier)
return collectionView
}()
...
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
//let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath)
//cell.backgroundColor = .green
guard let cell = collectionView.dequeueReusableCell(
withReuseIdentifier: photoCollectionViewCell.identifier,
for: indexPath
) as? photoCollectionViewCell else {
fatalError()
}
cell.configure(with: images[indexPath.row])
return cell
}
...
Basically im getting an error in the fatalError() while casting to "photoCollectionViewCell", which is another class that contains the images to show in the carrousel. The error doesn't show any other message than the fatal error message so i have no idea why is failing.
If instead of casting to the "photoCollectionViewCell" i use the two commented lines i get the green cells so at this point im very lost.
It would be very helpful any ideas to solve this. Thanks in advance!!!
PD: sorry for my bad english