I am getting the following error when I tried to load NSCollectionviewItem in: collectionView(_ collectionView: NSCollectionView, itemForRepresentedObjectAt indexPath: IndexPath)
Error :
could not instantiate an NSViewController for a nib in the "CollectionViewCell" bundle because the bundle has not been loaded
I am loading CollectionViewItem from xib
Written following code in viewDidLoad
let nib = NSNib(nibNamed: "CollectionViewCell", bundle: nil)
if #available(OSX 10.11, *) {
self.collectionView.register(nib, forItemWithIdentifier: "CollectionViewCell")
}
func collectionView(_ collectionView: NSCollectionView, itemForRepresentedObjectAt indexPath: IndexPath) -> NSCollectionViewItem {
if #available(OSX 10.11, *) {
let item = collectionView.makeItem(withIdentifier: "CollectionViewCell", for: indexPath)
return item
}
return NSCollectionViewItem()
}