0

I have a NSCollectionView in my NSViewController and I pass the data as follow:

func collectionView(_ collectionView: NSCollectionView, itemForRepresentedObjectAt indexPath: IndexPath) -> NSCollectionViewItem {
        guard let item = collectionView.makeItem(withIdentifier: NSUserInterfaceItemIdentifier("ExploreMainCollectionItem"), for: indexPath) as? ExploreMainCollectionItem else { fatalError() }
        
        item.categoryName.stringValue = exploreData.exploreCategories[indexPath.item].name
        item.exploreCategoryIndex = indexPath.item
        
        return item
    }

In the NSCollectionViewItem, I have another NSCollectionView. When I try to use the data passed from previous VC, it is not what I passed and always the default value.

enter image description here

I tried reloading the collectionview inside a didSet on the exploreCategoryIndex and it has changed values but when it goes to the collectionview methods, it is always the default value of exploreCategoryIndex.

Paulw11
  • 108,386
  • 14
  • 159
  • 186
Mirath
  • 1
  • 1

0 Answers0