Appname.ViewsVC collectionView: cellForItemAtIndexPath:]: unrecognized selector sent to the instance

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

// cell configuration
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

    // pic setup
    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.

+4
source share
1 answer

, UICollectionViewDataSource UICollectionViewDelegate View.

class ViewsVC: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {

+16

Source: https://habr.com/ru/post/1663432/


All Articles