unrecognized selector sent to instance 0x8c9a6d0
well, seems you don't set the right instance as datasource.
the runtime is trying to call the method on a UIViewController. That is wrong as that cannot be the right class.
my guess is that you haven't set your view controller's class in the xib and therefore a default UIViewController is used
To fix unrecognized selector sent to instance 0x8c9a6d0, you must respect two rules:
1) You have to confirm that all IBOutlet connections exist in cell class. Confirm IBOutlet connection by clicking an item in your cell, for ex. Title label and in the right side of XCode click "Show the Connections inspector" round icon with right arrow "->". You you have many connections and you are confused, please remove all connections and connect them again in cell class.
2) You have to add delegates and datasource for that collectionView in viewDidLoad:
override func viewDidLoad() {
super.viewDidLoad()
collectionView.delegate = self
collectionView.dataSource = self
}
PS. If you have uicollectionview cell inside tableview cell you must add delegates and datasource inside that cell class, adding with storyboard with drag and not seems not working on Xcode 10.1.
override func awakeFromNib() {
super.awakeFromNib()
collectionView.delegate = self
collectionView.dataSource = self
}
Put the protocols : UICollectionViewDelegate and UICollectionViewDataSource after UIViewController to access UICollectionView delegate methods.