Uicollectionview cell not loading binary data

I am trying to load a core data binary image on a uicollectionview imageview cell. When I segue to the collection view controlller I am getting the error message “Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value” at theIssues.reloadData(). If I comment that out the screen is just black. I have added a picture below where I put a break point and what is in the debugg area.

              class theCollection: UICollectionViewCell {


       var backButton = UIButton()
     @IBOutlet var dx : UIImageView!


     }

      class collectionVIEW: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource{

     var users = [Item]()
      @IBOutlet var theIssues: UICollectionView!

    override func viewDidLoad() {
super.viewDidLoad()

users = AppDelegate.cdHandler.fetchObject()


theIssues.reloadData()
     }


      func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return users.count
     }

 func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! theCollection


if let imageData = users[indexPath.row].image {

    let coredataLoadedimage = UIImage(data: imageData)
    cell.dx.image = coredataLoadedimage
    //
}

return cell
 }}

49%20AM
07%20PM

The last line of the debug window says that theIssues is nil.

Since you don’t set it in code anywhere, and it has the @IBOutlet attribute, it needs to be connected to a UICollectionView on your storyboard.

Added a picture whats going on based on the photo.

This topic was automatically closed after 166 days. New replies are no longer allowed.