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
}}