I create a collection view and get the following error.
Application terminated due to an uncaught exception "NSInvalidArgumentException", reason: '- [appname.ViewsVC collectionView: cellForItemAtIndexPath:]: unrecognized selector sent to the instance
Here is the code where I custom cell
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ViewsCell", for: indexPath) as! ViewsCell
cell.fullnameLbl.text = self.viewsArray[(indexPath as NSIndexPath).row].capitalizeEachWord
avaArray[indexPath.row].getDataInBackground { (data:Data?, error:Error?) in
if error == nil {
cell.avaImg.image = UIImage(data: data!)
}
}
return cell
}
I created the collection view and cell in the storyboard and gave them the correct identifiers. I also connected the UIimageView and label to the cell class.
Any ideas what might be wrong.
source
share