trouble passing data from model to a collection view
See the results.png file for an image of the Desired Result verses the Actual Result this code gives
I want the collectionView(numberOfItemsInSection) function to return the number of items (5) in my [data] array but it instead returns the hard-coded value (3) because viewController is always nil when this function is called. I also make use of the [data] array in the collectionView(cellForItemAt) function, and that works fine because viewController is not nil by that time.
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
if let numData = viewController?.data.count {
return numData
} else {
return 3
}
}